tmux Cheatsheet
Workflow
Use this tmux reference while you build software engineering projects, review code, or refresh the syntax you reach for most.
Everyday Patterns
| Situation | Pattern |
|---|---|
| Long build or migration | Start it, prefix d, come back with tmux attach |
| Remote work | ssh host -t tmux new -A -s main, never the reverse |
| Server plus logs | prefix " then run the server above and tail -f below |
| Read a big log | prefix z to zoom, prefix [ for copy mode, / to search |
| Same command on many hosts | One pane per host, then synchronize-panes on |
| One project per workspace | One session per repo, switch with prefix s or a sessionizer |
| Pair debugging | Both attach to the same session |
| Quick scratch shell | prefix c, work, prefix & to kill it |
| Reorganize after the fact | prefix ! to break a pane out, join-pane to pull it back |
Vim and tmux Together
The two need three settings to stop fighting each other.
set -sg escape-time 10 # otherwise leaving Insert mode lags set -g focus-events on # so Vim's autoread and autosave fire set -g default-terminal "tmux-256color" set -ga terminal-overrides ",*256col*:Tc"
With vim-tmux-navigator on both sides, Ctrl-h/j/k/l moves between Vim splits and tmux panes with one set of keys, crossing the boundary transparently.
set -g @plugin 'christoomey/vim-tmux-navigator'
" in your vimrc Plug 'christoomey/vim-tmux-navigator'
Sending code from an editor pane to a shell pane is a two-line binding, and it is how people build a REPL workflow without any plugin:
bind -n M-Enter run-shell "tmux send-keys -t .+ Up Enter"Minimal Keys to Memorize
| Keys | Action |
|---|---|
tmux new -s name | Start |
tmux a -t name | Reattach |
prefix d | Detach |
prefix c | New window |
prefix n prefix p prefix 1-9 | Move between windows |
prefix , | Rename window |
prefix % prefix " | Split |
prefix arrows | Move between panes |
prefix z | Zoom |
prefix x | Kill pane |
prefix [ | Copy mode, scroll back |
prefix ? | Every other binding |
Everything else in this reference is an optimization on top of those twelve.
Where to Go Next
man tmuxis the complete reference, and it is unusually well written. TheFORMATSandCOMMANDSsections repay reading.prefix ?lists your live bindings, including your own.tmux list-commandsprints every command with its arguments.- The
tmux-pluginsorganization on GitHub holdstmux-sensible,tmux-resurrect, andtmux-continuum, which is where most people start with plugins.