tmux Cheatsheet

Plugins

Use this tmux reference while you build software engineering projects, review code, or refresh the syntax you reach for most.

Plugins (TPM)

git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
# at the bottom of ~/.tmux.conf
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'christoomey/vim-tmux-navigator'

set -g @continuum-restore 'on'
set -g @resurrect-strategy-vim 'session'

run '~/.tmux/plugins/tpm/tpm'
KeysTPM action
prefix IInstall new plugins
prefix UUpdate plugins
prefix M-uRemove plugins no longer listed
PluginAdds
tmux-sensibleSane defaults everyone ends up setting
tmux-resurrectSave and restore sessions across reboots (prefix Ctrl-s, prefix Ctrl-r)
tmux-continuumAutomatic periodic saving for resurrect
vim-tmux-navigatorOne set of Ctrl-hjkl keys for Vim splits and tmux panes
tmux-yankClipboard integration that just works per platform
tmux-fzfFuzzy find sessions, windows, panes

Installing Without TPM

TPM is convenient but it is only a git clone plus a run-shell line. Doing it by hand is fine, and it is what you want on a server where you would rather not add a plugin manager.

mkdir -p ~/.tmux/plugins
git clone https://github.com/tmux-plugins/tmux-resurrect ~/.tmux/plugins/tmux-resurrect
run-shell ~/.tmux/plugins/tmux-resurrect/resurrect.tmux

Order matters: run-shell lines and the run '…/tpm' line go at the bottom of the config, after your own set and bind lines, so your settings win where they overlap.

tmux-sensible

Worth reading rather than just installing, because it is a short list of the defaults nearly everyone converges on.

set -s escape-time 0
set -g history-limit 50000
set -g display-time 4000
set -g status-interval 5
set -g default-terminal "screen-256color"
set -g focus-events on
setw -g aggressive-resize on
bind C-p previous-window
bind C-n next-window

If you set these yourself, you do not need the plugin.

Resurrect and Continuum

set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

set -g @resurrect-capture-pane-contents 'on'
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-processes 'ssh psql "~rails server" "npm run dev"'
set -g @continuum-restore 'on'
set -g @continuum-save-interval '15'
set -g @continuum-boot 'on'
OptionDoes
@resurrect-processesAn allowlist of commands to restart, not just the shell
@resurrect-capture-pane-contentsSave scrollback too
@resurrect-strategy-vim / -nvimRestore the editor's own session file
@continuum-restoreRestore automatically when the server starts
@continuum-save-intervalMinutes between automatic saves, 0 disables

Saved state lives in ~/.local/share/tmux/resurrect/, as plain text files you can inspect.

Plugin Troubleshooting

SymptomCause
prefix I does nothingThe run '~/.tmux/plugins/tpm/tpm' line is missing or not last
A plugin's bindings are ignoredYour own bind came after it, or vice versa. Check list-keys.
Config errors after adding a plugintmux stops reading the file at the first error. Fix that line.
Plugin works locally, not on a serverThe clone did not happen there. Plugins are not synced by your dotfiles unless you vendor them.
tmux list-keys | grep -i resurrect
ls ~/.tmux/plugins
tmux source-file ~/.tmux.conf