# 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 } bind WheelUpPane send-keys -N 2 scroll-up bind WheelDownPane send-keys -N 2 scroll-Down bind F12 send-keys F12 # View current pane in editor bind y { capture-pane -J save-buffer /tmp/tmux-buffer delete-buffer display-popup -E -w 90% -h 80% "nvim /tmp/tmux-buffer" } # View current buffer in editor bind Y { capture-pane -J -S - -E - save-buffer /tmp/tmux-buffer delete-buffer display-popup -E -w 90% -h 80% "nvim /tmp/tmux-buffer" } bind t display-popup -E -h 70% -w 60% -d "${HOME}" bind c display-menu \ calendar c { display-popup -w 33% -h 70% "cal -my" } \ time t { display-popup -w 50% -h 17% "watch -t -n 1 'figlet -ct -f big \"$(date \"+%H : %M : %S\")\"'" } \ weather w { display-popup -h 80% -w 60% "zsh -ic 'weather \$CITY'" } # 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 ~" bind x confirm-before -p "kill current session? (y/n)" "kill-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\"" bind C-x confirm-before -p "kill other sessions? (y/n)" "kill-session -a" bind q confirm-before -p "kill current pane? (y/n)" "kill-pane" bind Q kill-window bind C-q confirm-before -p "kill other windows? (y/n)" "kill-window -a" bind d detach bind D choose-client -Z bind C-d detach-other bind r command-prompt -I '#W' -p "New window name:" "rename-window '%%'" bind R command-prompt -I '#S' -p "New session name:" "rename-session '%%'" bind ';' command-prompt bind -n M-f toggle-zoom bind l choose-window -w -Z 'link-window -s "%%" -a' bind u unlink-window bind j choose-window -Z 'join-pane -s "%%"' bind Tab switch-client -l 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 -d -Z -t '{right-of}' bind -n M-H swap-pane -d -Z -t '{left-of}' bind -n M-J swap-pane -d -Z -t '{down-of}' bind -n M-K swap-pane -d -Z -t '{up-of}' # Sync panes bind o toggle-synchronize-panes bind O setw synchronize-panes off bind i detect-panes # Windows navigation bind -n M-1 if-shell 'tmux new-window -t 1 -n 1 -c "#{pane_current_path}"' '' 'select-window -t 1' bind -n M-2 if-shell 'tmux new-window -t 2 -n 2 -c "#{pane_current_path}"' '' 'select-window -t 2' bind -n M-3 if-shell 'tmux new-window -t 3 -n 3 -c "#{pane_current_path}"' '' 'select-window -t 3' bind -n M-4 if-shell 'tmux new-window -t 4 -n 4 -c "#{pane_current_path}"' '' 'select-window -t 4' bind -n M-5 if-shell 'tmux new-window -t 5 -n 5 -c "#{pane_current_path}"' '' 'select-window -t 5' bind -n M-6 if-shell 'tmux new-window -t 6 -n 6 -c "#{pane_current_path}"' '' 'select-window -t 6' bind -n M-7 if-shell 'tmux new-window -t 7 -n 7 -c "#{pane_current_path}"' '' 'select-window -t 7' bind -n M-8 if-shell 'tmux new-window -t 8 -n 8 -c "#{pane_current_path}"' '' 'select-window -t 8' bind -n M-9 if-shell 'tmux new-window -t 9 -n 9 -c "#{pane_current_path}"' '' 'select-window -t 9' bind -n M-0 if-shell 'tmux new-window -t 10 -n 10 -c "#{pane_current_path}"' '' 'select-window -t 10' # 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' set -g main-pane-width '$_tmux_other_pane_size' set -g main-pane-height '100%' # Swapping windows bind -r "<" swap-window -d -t -1 bind -r ">" swap-window -d -t +1 # Windows splitting bind -n M-Enter split-window -d -h -b -l $_tmux_other_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}" bind -n M-q stash-pane bind -n M-r default-layout # Swap left pane bind -n M-Tab swap-pane -t '{left-of}' # Copy mode setw -g mode-keys vi bind v copy-mode bind C-p choose-buffer bind -T copy-mode-vi C-v send-keys -X rectangle-toggle bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard" bind -T copy-mode-vi Y send-keys -X copy-selection-and-cancel bind MouseDrag1Pane copy-mode bind -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard" bind -r p run-shell "xclip -selection clipboard -o | tmux load-buffer -; tmux paste-buffer -p" bind -r P paste-buffer -p ## 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 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 a display-popup -EE -w 80% -h 80% -B '~/.local/bin/tmux_attach_session.sh' bind s display-popup -EE -w 80% -h 80% -B '~/.local/bin/tmux_start_session.sh' bind S display-popup -EE -w 40% -h 80% -B '~/.local/bin/tmux_start_projects.sh' bind k display-popup -EE -w 80% -h 80% -B '~/.local/bin/tmux_kill_sessions.sh'