# vim: ft=tmux set -g prefix C-b bind C-b send-prefix # Toggle local tmux mappings to allow control remote tmux bind -T root F12 \ set prefix None \;\ set key-table off \;\ set status off bind -T off F12 \ set -u prefix \;\ set -u key-table \;\ set status on ## Toggle remote tmux mappings bind F12 send-keys F12 # Choose session with key index starting from 1 bind s choose-tree -ZsK '#{?#{e|<:#{line},9},#{e|+:1,#{line}},#{?#{e|<:#{line},35},M-#{a:#{e|+:97,#{e|-:#{line},9}}},}}' # Switch new session bind n new-session -c ~ # Switch new named session bind N command-prompt -p "New session:" "new-session -A -s '%1' -c ~" # Kill session bind x confirm-before -p "kill current session? (y/n)" "kill-session" # Kill last session bind X confirm-before -p "kill last session [#{client_last_session}]? (y/n)" "kill-session -t #{client_last_session} \; display-message \"Killed last session\"" # Kill other sessions bind C-x confirm-before -p "kill other sessions? (y/n)" "kill-session -a" # kill pane bind q confirm-before -p "kill current pane? (y/n)" "kill-pane" # kill window bind Q kill-window # Kill other windows bind C-q confirm-before -p "kill other windows? (y/n)" "kill-window -a" bind r command-prompt -I '#W' -p "New window name:" "rename-window '%%'" bind R command-prompt -I '#S' -p "New session name:" "rename-session '%%'" # SSH Session bind H command-prompt -p "Remote host:" "new-session -s 'ssh-%1' -A ssh %1 \; set default-command 'ssh %1' \; set remain-on-exit on \; set detach-on-destroy on" # Call prompt via prefix ; bind ';' command-prompt # Zoom pane bind -n M-f resize-pane -Z # Link window bind l choose-window -w -Z 'link-window -s "%%" -a' bind u unlink-window # Join pane bind j choose-window -Z 'join-pane -s "%%"' # Reload config bind F5 reload-config # Panes navigation bind -n M-h select-pane -L bind -n M-l select-pane -R bind -n M-j select-pane -D bind -n M-k select-pane -U # Resizing bind -n C-M-l resize-pane -R bind -n C-M-h resize-pane -L bind -n C-M-j resize-pane -D bind -n C-M-k resize-pane -U # Swappings panes bind -n M-L swap-pane -t '{right-of}' bind -n M-H swap-pane -t '{left-of}' bind -n M-J swap-pane -t '{down-of}' bind -n M-K swap-pane -t '{up-of}' # Sync panes bind o if -F '#{pane_synchronized}' 'setw synchronize-panes off' 'setw synchronize-panes on' bind O setw synchronize-panes off # Detach bind C-d if -F '#{session_many_attached}' \ 'confirm-before -p "Detach other clients? (y/n)" "detach -a"' \ 'display "Session has only 1 client attached"' bind i "set -g display-time $_tmux_display_panes_time \; display-message \; display-panes \; set -g display-time $_tmux_display_time" # Windows navigation bind -n M-Tab last-window bind -n M-1 if-shell 'tmux select-window -t 1' '' 'new-window -t 1 -n 1 -c "#{pane_current_path}"' bind -n M-2 if-shell 'tmux select-window -t 2' '' 'new-window -t 2 -n 2 -c "#{pane_current_path}"' bind -n M-3 if-shell 'tmux select-window -t 3' '' 'new-window -t 3 -n 3 -c "#{pane_current_path}"' bind -n M-4 if-shell 'tmux select-window -t 4' '' 'new-window -t 4 -n 4 -c "#{pane_current_path}"' bind -n M-5 if-shell 'tmux select-window -t 5' '' 'new-window -t 5 -n 5 -c "#{pane_current_path}"' bind -n M-6 if-shell 'tmux select-window -t 6' '' 'new-window -t 6 -n 6 -c "#{pane_current_path}"' bind -n M-7 if-shell 'tmux select-window -t 7' '' 'new-window -t 7 -n 7 -c "#{pane_current_path}"' bind -n M-8 if-shell 'tmux select-window -t 8' '' 'new-window -t 8 -n 8 -c "#{pane_current_path}"' bind -n M-9 if-shell 'tmux select-window -t 9' '' 'new-window -t 9 -n 9 -c "#{pane_current_path}"' bind -n M-0 if-shell 'tmux select-window -t 10' '' 'new-window -t 10 -n 10 -c "#{pane_current_path}"' # Moving pane to window by Alt+Shift+Number bind -n 'M-!' if-shell 'tmux join-pane -d -h -t :1' '' 'break-pane -t 1 -d -n 1' bind -n 'M-@' if-shell 'tmux join-pane -d -h -t :2' '' 'break-pane -t 2 -d -n 2' bind -n 'M-#' if-shell 'tmux join-pane -d -h -t :3' '' 'break-pane -t 3 -d -n 3' bind -n 'M-$' if-shell 'tmux join-pane -d -h -t :4' '' 'break-pane -t 4 -d -n 4' bind -n 'M-%' if-shell 'tmux join-pane -d -h -t :5' '' 'break-pane -t 5 -d -n 5' bind -n 'M-^' if-shell 'tmux join-pane -d -h -t :6' '' 'break-pane -t 6 -d -n 6' bind -n 'M-&' if-shell 'tmux join-pane -d -h -t :7' '' 'break-pane -t 7 -d -n 7' bind -n 'M-*' if-shell 'tmux join-pane -d -h -t :8' '' 'break-pane -t 8 -d -n 8' bind -n 'M-(' if-shell 'tmux join-pane -d -h -t :9' '' 'break-pane -t 9 -d -n 9' bind -n 'M-)' if-shell 'tmux join-pane -d -h -t :10' '' 'break-pane -t 10 -d -n 10' _tmux_new_pane_size="30%" _tmux_main_pane_size="70%" # Hide pane bind -n M-q if-shell 'tmux join-pane -l $_tmux_main_pane_size -h -s stash' '' 'break-pane -d -n stash' # Swapping windows bind -r "<" swap-window -d -t -1 bind -r ">" swap-window -d -t +1 # Windows splitting bind -n M-Enter split-window -h -b -l $_tmux_new_pane_size -c "#{pane_current_path}" bind -n M-t split-window -v -l 20% -c "#{pane_current_path}" bind \\ split-window -h -c "#{pane_current_path}" bind - split-window -v -c "#{pane_current_path}" # Default layout size bind -n M-u resize-pane -x $_tmux_main_pane_size # Copy mode setw -g mode-keys vi bind v copy-mode bind -r p paste-buffer bind C-p choose-buffer ## Toggle selection bind -T copy-mode-vi v if -F '#{selection_active}' 'send-keys -X clear-selection' 'send-keys -X begin-selection' bind -T copy-mode-vi y send-keys -X copy-selection-and-cancel bind -T copy-mode-vi C-v send-keys -X rectangle-toggle bind -T copy-mode-vi Escape send-keys -X cancel bind -T copy-mode-vi C-c send-keys -X cancel bind -T copy-mode-vi q send-keys -X cancel bind -T copy-mode-vi WheelUpPane select-pane \; send-keys -X -N 2 scroll-up bind -T copy-mode-vi WheelDownPane select-pane \; send-keys -X -N 2 scroll-down # Session managment bind 1 run-shell ~/.tmux/01.sh bind 2 run-shell ~/.tmux/02.sh bind 3 run-shell ~/.tmux/03.sh bind 4 run-shell ~/.tmux/04.sh bind 5 run-shell ~/.tmux/05.sh bind 6 run-shell ~/.tmux/06.sh bind 7 run-shell ~/.tmux/07.sh bind 8 run-shell ~/.tmux/08.sh bind 9 run-shell ~/.tmux/09.sh bind 0 run-shell ~/.tmux/10.sh # Switch to last session bind Tab switch-client -l