aliquote.org

Tmux shortcuts

After my Vim keymappings cheatsheet, here are my current settings for Tmux. Again, I published several blog posts related to my Tmux settings in the past.

Initially I defined a second prefix key, and then I decided that C-b is perfectly good for me, and I rather add a new “hot key” in the name of “Meta” (Alt). Ubuntu relies on the Super key for its mappings, while the Ctrl key is used by Vim, Irssi, and many other of my CLI software. The Alt key is pretty handy for me, it reminds of my Emacs time and it does not interfere with other environment that I know or use regularly (beside folks using both the Ctrl and Alt key in some Vim plugins).

Compared to Neovim, my requirements are even more minimalistic since I don’t use any extra plugins or frameworks. In what follows, I only show what I added to my .tmux.conf file.

Mapping Command Role
M-Hresize-pane -L 4resize pane toward left
M-Jresize-pane -D 4resize pane toward bottom
M-Kresize-pane -U 4resize pane toward up
M-Lresize-pane -R 4resize pane toward right
M-!split-window -f -l 10 -c "#{pane_current_path}"bottom popup terminal
M--display-popup -E -w 80% -h 80% "lf"lf file manager in a popup
M-:command-promptdisplay command prompt
M-<swap-pane -Umove pane to the left
M->swap-pane -Dmove pane to the right
M-Enternew-windownew window
M-=choose-bufferselect among paste buffers
M-Downswap-window -t +1move window to the right
M-Upswap-window -t -1move window to the left
M-Leftprevious-windowselect next window to the left
M-Rightnext-windowselect next window to the right
M-kprevious-windowselect next window to the left
M-jnext-windowselect next window to the right
M-Oswitch-client -lchange current Tmux client and session
M-ncommand-prompt -p "New Session:" "new-session -A -s '%%'"create new session
M-X"kill-session -a"kill all other sessions
M-xkill-sessionkill current sessions
M-hchoose-window 'join-pane -h -s "%%"'attach pane to another window
M-Vselect-layout even-horizontalarrange panes using horizontal layout
M-Sselect-layout even-verticalarrange panes using vertical layout
M-llast-windowgo to last window
M-mcommand-prompt -p "Search man pages for:" "new-window 'exec man %%'"query man page in a temporary window
M-oselectp -t :.+go to other split
M-prun-shell -b ~/bin/tmux-fzfselect picker for window
M-ssplit-window -v -c "#{pane_current_path}"create horizontal split
M-vsplit-window -v -c "#{pane_current_path}"create vertical split
M-tbreak-paneconvert pane to proper window
M-wchoose-windowshow list of sessions and windows
M-ycopy-modeactivate copy mode
M-zresize-pane -Zmaximize current pane
C-b C-gsetw synchronize-panessynchronize panes
C-b C-mif -F '#{s/off//:mouse}' 'set -g mouse off; display-message "mouse: off"' 'set -g mouse on; display-message "mouse: on"'toggle mouse mode on/off
C-b C-prun "tmux capture-pane; tmux save-buffer ~/tmp/tmux-\"$(date +%FT%T)\""save buffer to a file
C-b C-rsource-file ~/.tmux.conf \; display-message "Config reloaded"reload Tmux config
C-b C-sif -F '#{s/off//:status}' 'set status off' 'set status on'toggle status bar on/off

For copy-pasting, I have the following settings:

bind Y copy-mode
setw -g mode-keys vi
bind-key -T copy-mode-vi v send -X begin-selection
bind-key -T copy-mode-vi 'C-v' send -X rectangle-toggle
set -g set-clipboard off
bind-key -T copy-mode-vi y send -X copy-pipe-and-cancel "xclip -i -selection clipboard"
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xclip -i -selection clipboard"