Modernize and clean up tmux configs
This commit is contained in:
+82
-2
@@ -1,2 +1,82 @@
|
||||
# run-shell "~/.tmux/verify_tmux_version.sh"
|
||||
source-file "~/.tmux/tmux_3.1c.conf"
|
||||
# ----------------------------------------------------------------------------
|
||||
# Prefix
|
||||
# ----------------------------------------------------------------------------
|
||||
set -g prefix C-a
|
||||
unbind C-b
|
||||
bind C-a send-prefix
|
||||
bind Tab last-window
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# General behavior
|
||||
# ----------------------------------------------------------------------------
|
||||
set-option -g set-titles on
|
||||
set -g default-terminal "screen-256color"
|
||||
set -g history-limit 10000
|
||||
set -sg escape-time 1
|
||||
set-option -g base-index 1
|
||||
setw -g pane-base-index 1
|
||||
setw -g aggressive-resize on
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Windows and panes
|
||||
# ----------------------------------------------------------------------------
|
||||
bind T swap-window -t 1
|
||||
bind | split-window -h -c "#{pane_current_path}"
|
||||
bind - split-window -v -c "#{pane_current_path}"
|
||||
bind c new-window -c "#{pane_current_path}"
|
||||
|
||||
bind h select-pane -L
|
||||
bind j select-pane -D
|
||||
bind k select-pane -U
|
||||
bind l select-pane -R
|
||||
|
||||
# Smart pane switching with awareness of vim splits
|
||||
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
||||
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
|
||||
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
|
||||
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
|
||||
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
|
||||
bind -n 'C-\' if-shell "$is_vim" "send-keys 'C-\\'" "select-pane -l"
|
||||
|
||||
bind -r C-h select-window -t :-
|
||||
bind -r C-l select-window -t :+
|
||||
|
||||
bind a setw synchronize-panes
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Copy mode and mouse
|
||||
# ----------------------------------------------------------------------------
|
||||
setw -g mode-keys vi
|
||||
set-option -g -q mouse on
|
||||
|
||||
bind y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy'
|
||||
bind C-y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy'
|
||||
|
||||
# tmux renamed the copy-mode key table (vi-copy -> copy-mode-vi) and changed
|
||||
# bind-key's table flag (-t -> -T) in 2.4. Source the file matching the
|
||||
# running tmux so old tmux never parses syntax it doesn't understand.
|
||||
if-shell "tmux -V | awk '{print $2}' | awk -F. '{if ($1*1000+$2 < 2004) exit 0; else exit 1}'" 'source-file ~/.tmux/legacy.conf' 'source-file ~/.tmux/modern.conf'
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Misc bindings
|
||||
# ----------------------------------------------------------------------------
|
||||
bind-key C run-shell "cal $(date +%Y)"
|
||||
bind r source-file ~/.tmux.conf \; display "Reloaded config"
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Powerline (guarded so machines without it don't error on load)
|
||||
# ----------------------------------------------------------------------------
|
||||
run-shell "command -v powerline-daemon >/dev/null 2>&1 && powerline-daemon -q; true"
|
||||
run-shell "command -v powerline-config >/dev/null 2>&1 && powerline-config tmux setup; true"
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Plugins (TPM)
|
||||
# ----------------------------------------------------------------------------
|
||||
set -g @plugin 'tmux-plugins/tpm'
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
|
||||
# Local overrides
|
||||
if-shell "[ -f ~/.tmux_local.conf ]" 'source ~/.tmux_local.conf'
|
||||
|
||||
# Initialize TPM (must be the last line)
|
||||
run '~/.tmux/plugins/tpm/tpm'
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
# tmux < 2.4 copy-mode key table (vi-copy, old -t flag) and mouse-wheel/
|
||||
# PageUp passthrough. Sourced conditionally from tmux.conf; see
|
||||
# tmux/modern.conf for tmux >= 2.4.
|
||||
|
||||
bind-key -t vi-copy PPage page-up
|
||||
bind-key -t vi-copy NPage page-down
|
||||
bind-key -t vi-copy WheelUpPane halfpage-up
|
||||
bind-key -t vi-copy WheelDownPane halfpage-down
|
||||
bind-key -t vi-copy v begin-selection
|
||||
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
unbind-key -t vi-copy Enter
|
||||
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
|
||||
bind-key -n PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage"
|
||||
bind-key -n WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
|
||||
bind-key -n WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
|
||||
@@ -1,42 +1,17 @@
|
||||
# PREFIX | splits horizontally and PREFIX - splits vertically
|
||||
bind | split-window -h -c "#{pane_current_path}"
|
||||
bind - split-window -v -c "#{pane_current_path}"
|
||||
# tmux >= 2.4 copy-mode key table and mouse-wheel/PageUp passthrough.
|
||||
# Sourced conditionally from tmux.conf; see tmux/legacy.conf for older tmux.
|
||||
|
||||
# open new window with pwd
|
||||
bind c new-window -c "#{pane_current_path}"
|
||||
|
||||
# use vim keybindings in copy mode
|
||||
setw -g mode-keys vi
|
||||
|
||||
# Copy Mode
|
||||
bind-key -T copy-mode-vi PPage send-keys -X page-up
|
||||
bind-key -T copy-mode-vi NPage send-keys -X page-down
|
||||
|
||||
# Mouse Wheel
|
||||
bind-key -T copy-mode-vi WheelUpPane send-keys -X halfpage-up
|
||||
bind-key -T copy-mode-vi WheelDownPane send-keys -X halfpage-down
|
||||
|
||||
# v selection
|
||||
bind-key -T copy-mode-vi v send-keys -X begin-selection
|
||||
bind-key -T copy-mode-vi y send-keys -X copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
|
||||
# make enter use copy pipe
|
||||
unbind -T copy-mode-vi Enter
|
||||
unbind-key -T copy-mode-vi Enter
|
||||
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
|
||||
set-option -g -q mouse on
|
||||
set-option -g -q mouse-resize-pane on
|
||||
set-option -g -q mouse-select-pane on
|
||||
set-option -g -q mouse-select-window on
|
||||
|
||||
# Enable middle click in urxvt
|
||||
set-option -ga terminal-override ',rxvt-uni*:XT:Ms=\E]52;%p1%s;%p2%s\007'
|
||||
|
||||
# Copy Mode
|
||||
# Let mouse wheel / PageUp pass through to apps using the alternate screen
|
||||
# (vim, less, etc.) instead of always entering copy-mode
|
||||
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage"
|
||||
|
||||
# Mouse Wheel
|
||||
bind-key -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
|
||||
bind-key -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
|
||||
|
||||
source ~/.tmux/tmux_shared.conf
|
||||
@@ -1,37 +0,0 @@
|
||||
# PREFIX | splits horizontally and PREFIX - splits vertically
|
||||
bind | split-window -h
|
||||
bind - split-window -v
|
||||
|
||||
# mouse support
|
||||
set -g mode-mouse on # scrolling
|
||||
set -g mouse-select-pane on # clicking into panes
|
||||
set -g mouse-resize-pane on # resizing panes
|
||||
set -g mouse-select-window on # select windows
|
||||
|
||||
# toggle mouse support
|
||||
bind m \
|
||||
set -g mode-mouse on \;\
|
||||
set -g mouse-resize-pane on \;\
|
||||
set -g mouse-select-pane on \;\
|
||||
set -g mouse-select-window on \;\
|
||||
display 'Mouse: ON'
|
||||
|
||||
bind M \
|
||||
set -g mode-mouse off \;\
|
||||
set -g mouse-resize-pane off \;\
|
||||
set -g mouse-select-pane off \;\
|
||||
set -g mouse-select-window off \;\
|
||||
display 'Mouse: OFF'
|
||||
|
||||
# ----------------------
|
||||
# set some pretty colors
|
||||
# ----------------------
|
||||
# set pane colors - hilight the active pane
|
||||
# set-option -g pane-border-fg colour235 #base02
|
||||
# set-option -g pane-active-border-fg colour240 #base01
|
||||
|
||||
# # colorize messages in the command line
|
||||
# set-option -g message-bg black #base02
|
||||
# set-option -g message-fg brightred #orange
|
||||
|
||||
source "$HOME/.tmux/tmux_shared.conf"
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
source "$HOME/.tmux/tmux_shared.conf"
|
||||
@@ -1,48 +0,0 @@
|
||||
# PREFIX | splits horizontally and PREFIX - splits vertically
|
||||
bind | split-window -h -c "#{pane_current_path}"
|
||||
bind - split-window -v -c "#{pane_current_path}"
|
||||
|
||||
# open new window with pwd
|
||||
bind c new-window -c "#{pane_current_path}"
|
||||
|
||||
# PREFIX T makes current window index 1
|
||||
bind T swap-window -t 1
|
||||
|
||||
# use vim movement for panes
|
||||
bind h select-pane -L
|
||||
bind j select-pane -D
|
||||
bind k select-pane -U
|
||||
bind l select-pane -R
|
||||
|
||||
# mouse support
|
||||
set-option -g -q mouse on
|
||||
|
||||
# Copy Mode
|
||||
bind-key -t root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage"
|
||||
bind-key -t vi-copy PPage page-up
|
||||
bind-key -t vi-copy NPage page-down
|
||||
# Mouse Wheel
|
||||
bind-key -t root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
|
||||
bind-key -t root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
|
||||
bind-key -t vi-copy WheelUpPane halfpage-up
|
||||
bind-key -t vi-copy WheelDownPane halfpage-down
|
||||
|
||||
# Make sure the client is always using the correct environment
|
||||
# eval $(tmux switch-client \; show-environment -s)
|
||||
|
||||
# Copy/Paste
|
||||
#
|
||||
# provide access to clipboard
|
||||
# set-option -g default-command "reattach-to-user-namespace -l zsh"
|
||||
# set-window-option -g automatic-rename on
|
||||
|
||||
# use vim keybindings in copy mode
|
||||
setw -g mode-keys vi
|
||||
|
||||
# v selection
|
||||
bind-key -t vi-copy v begin-selection
|
||||
bind-key -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
|
||||
# make enter use copy pipe
|
||||
unbind -t vi-copy Enter
|
||||
bind-key -t vi-copy Enter copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
@@ -1,42 +0,0 @@
|
||||
# PREFIX | splits horizontally and PREFIX - splits vertically
|
||||
bind | split-window -h -c "#{pane_current_path}"
|
||||
bind - split-window -v -c "#{pane_current_path}"
|
||||
|
||||
# open new window with pwd
|
||||
bind c new-window -c "#{pane_current_path}"
|
||||
|
||||
# use vim keybindings in copy mode
|
||||
setw -g mode-keys vi
|
||||
|
||||
# Copy Mode
|
||||
bind-key -T copy-mode-vi PPage send-keys -X page-up
|
||||
bind-key -T copy-mode-vi NPage send-keys -X page-down
|
||||
|
||||
# Mouse Wheel
|
||||
bind-key -T copy-mode-vi WheelUpPane send-keys -X halfpage-up
|
||||
bind-key -T copy-mode-vi WheelDownPane send-keys -X halfpage-down
|
||||
|
||||
# v selection
|
||||
bind-key -T copy-mode-vi v send-keys -X begin-selection
|
||||
bind-key -T copy-mode-vi y send-keys -X copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
|
||||
# make enter use copy pipe
|
||||
unbind -T copy-mode-vi Enter
|
||||
bind-key -T copy-mode-vi Enter send-keys -X copy-pipe "reattach-to-user-namespace pbcopy"
|
||||
|
||||
set-option -g -q mouse on
|
||||
set-option -g -q mouse-resize-pane on
|
||||
set-option -g -q mouse-select-pane on
|
||||
set-option -g -q mouse-select-window on
|
||||
|
||||
# Enable middle click in urxvt
|
||||
set-option -ga terminal-override ',rxvt-uni*:XT:Ms=\E]52;%p1%s;%p2%s\007'
|
||||
|
||||
# Copy Mode
|
||||
bind-key -T root PPage if-shell -F "#{alternate_on}" "send-keys PPage" "copy-mode -e; send-keys PPage"
|
||||
|
||||
# Mouse Wheel
|
||||
bind-key -T root WheelUpPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; copy-mode -e; send-keys -M"
|
||||
bind-key -T root WheelDownPane if-shell -F -t = "#{alternate_on}" "send-keys -M" "select-pane -t =; send-keys -M"
|
||||
|
||||
source ~/.tmux/tmux_shared.conf
|
||||
@@ -1,110 +0,0 @@
|
||||
# use UTF8
|
||||
# set -g utf8
|
||||
# set-window-option -g utf8 on
|
||||
|
||||
# 256 color mode
|
||||
set -g default-terminal "screen-256color"
|
||||
# set-option -sa terminal-overrides ',screen*:RGB'
|
||||
# set-option -ga terminal-overrides ',screen*:Tc'
|
||||
# set-option -sa terminal-overrides ',xterm*:RGB'
|
||||
# set-option -ga terminal-overrides ',xterm*:Tc'
|
||||
# set-option -sa terminal-overrides ',tmux*:RGB'
|
||||
# set-option -ga terminal-overrides ',tmux*:Tc'
|
||||
# set-option -sa terminal-overrides ',rxvt*:RGB'
|
||||
# set-option -ga terminal-overrides ',rxvt*:Tc'
|
||||
|
||||
# Properly handle ssh agent forwarding when reconnecting to session
|
||||
# set-environment -g 'SSH_AUTH_SOCK' ~/.ssh/ssh_auth_sock
|
||||
|
||||
set-option -g set-titles on
|
||||
# Tmux attach will create a new session if one doesn't exist
|
||||
# new-session -n $HOST
|
||||
|
||||
# set scrollback history
|
||||
set -g history-limit 10000
|
||||
|
||||
# set Ctrl-a as prefix and unbind Ctrl-b
|
||||
set -g prefix C-a
|
||||
unbind C-b
|
||||
|
||||
# last active window
|
||||
# bind-key C-a last-window
|
||||
bind Tab last-window
|
||||
|
||||
# pass prefix through to application
|
||||
bind C-a send-prefix
|
||||
|
||||
# don't constrain size unless smaller client looking at window
|
||||
setw -g aggressive-resize on
|
||||
|
||||
# set command delay
|
||||
set -sg escape-time 1
|
||||
|
||||
# set base index to 1 rather than 0
|
||||
set-option -g base-index 1
|
||||
setw -g pane-base-index 1
|
||||
|
||||
# use PREFIX-r to reload config
|
||||
bind r source-file ~/.tmux/tmux_shared.conf \; display "Reloaded config"
|
||||
|
||||
# PREFIX T makes current window index 1
|
||||
bind T swap-window -t 1
|
||||
|
||||
# use vim movement for panes
|
||||
bind h select-pane -L
|
||||
bind j select-pane -D
|
||||
bind k select-pane -U
|
||||
bind l select-pane -R
|
||||
|
||||
# Smart pane switching with awareness of vim splits
|
||||
is_vim='echo "#{pane_current_command}" | grep -iqE "(^|\/)g?(view|n?vim?)(diff)?$"'
|
||||
bind -n C-h if-shell "$is_vim" "send-keys C-h" "select-pane -L"
|
||||
bind -n C-j if-shell "$is_vim" "send-keys C-j" "select-pane -D"
|
||||
bind -n C-k if-shell "$is_vim" "send-keys C-k" "select-pane -U"
|
||||
bind -n C-l if-shell "$is_vim" "send-keys C-l" "select-pane -R"
|
||||
bind -n 'C-\' if-shell "$is_vim" "send-keys 'C-\\'" "select-pane -l"
|
||||
|
||||
# bind C-h and C-l to cycle through panes
|
||||
bind -r C-h select-window -t :-
|
||||
bind -r C-l select-window -t :+
|
||||
|
||||
# Synchonize keyboard input across panes
|
||||
bind a setw synchronize-panes
|
||||
|
||||
# open calendar
|
||||
bind-key C run-shell "cal $(date +%Y)"
|
||||
|
||||
# Make sure the client is always using the correct environment
|
||||
# eval $(tmux switch-client \; show-environment -s)
|
||||
|
||||
bind y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '
|
||||
bind C-y run 'tmux save-buffer - | reattach-to-user-namespace pbcopy '1
|
||||
|
||||
# ----------------------
|
||||
# set some pretty colors
|
||||
# ----------------------
|
||||
# set pane colors - hilight the active pane
|
||||
# set-option -g pane-border-fg colour235 #base02
|
||||
# set-option -g pane-active-border-fg colour240 #base01
|
||||
|
||||
# Show active pane
|
||||
# set-window-option -g window-style 'bg=#181818'
|
||||
# set-window-option -g window-active-style 'bg=black'
|
||||
# set-window-option -g pane-active-border-style ''
|
||||
# set-window-option -g pane-active-border-style 'fg=#181818'
|
||||
|
||||
# colorize messages in the command line
|
||||
# set-option -g message-bg black #base02
|
||||
# set-option -g message-fg brightred #orange
|
||||
|
||||
# Powerline
|
||||
run-shell "powerline-daemon -q"
|
||||
run-shell "powerline-config tmux setup"
|
||||
# source-file $POWERLINE_ROOT/bindings/tmux/powerline.conf
|
||||
|
||||
# Tmux plugins
|
||||
set -g @plugin 'tmux-plugins/tpm'
|
||||
set -g @plugin 'tmux-plugins/tmux-sensible'
|
||||
|
||||
# Local overrides
|
||||
if-shell "[ -f ~/.tmux_local.conf ]" 'source ~/.tmux_local.conf'
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
verify_tmux_version() {
|
||||
tmux_home=~/.tmux
|
||||
tmux_version="$(tmux -V | cut -c 6-)"
|
||||
|
||||
# This is necessary because 3.1c gives a syntax error in bc
|
||||
# TODO Fix this it will break with the next tmux version
|
||||
if [[ $tmux_version -eq "3.1c"]] ; then
|
||||
source-file $tmux_home/tmux_3.1c.conf
|
||||
exit
|
||||
if [[ $(echo "$tmux_version >= 2.5" | bc) -eq 1 ]] ; then
|
||||
source-file $tmux_home/tmux_3.1c.conf
|
||||
exit
|
||||
elif [[ $(echo "$tmux_version >= 2.1" | bc) -eq 1 ]] ; then
|
||||
source-file $tmux_home/tmux_2.1_to_2.5.conf
|
||||
exit
|
||||
elif [[ $(echo "$tmux_version >= 1.9" | bc) -eq 1 ]] ; then
|
||||
source-file $tmux_home/tmux_1.9_to_2.1.conf
|
||||
exit
|
||||
else
|
||||
source-file $tmux_home/tmux_1.9_down.conf
|
||||
exit
|
||||
fi
|
||||
}
|
||||
|
||||
verify_tmux_version
|
||||
Reference in New Issue
Block a user