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

SituationPattern
Long build or migrationStart it, prefix d, come back with tmux attach
Remote workssh host -t tmux new -A -s main, never the reverse
Server plus logsprefix " then run the server above and tail -f below
Read a big logprefix z to zoom, prefix [ for copy mode, / to search
Same command on many hostsOne pane per host, then synchronize-panes on
One project per workspaceOne session per repo, switch with prefix s or a sessionizer
Pair debuggingBoth attach to the same session
Quick scratch shellprefix c, work, prefix & to kill it
Reorganize after the factprefix ! 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

KeysAction
tmux new -s nameStart
tmux a -t nameReattach
prefix dDetach
prefix cNew window
prefix n prefix p prefix 1-9Move between windows
prefix ,Rename window
prefix % prefix "Split
prefix arrowsMove between panes
prefix zZoom
prefix xKill 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 tmux is the complete reference, and it is unusually well written. The FORMATS and COMMANDS sections repay reading.
  • prefix ? lists your live bindings, including your own.
  • tmux list-commands prints every command with its arguments.
  • The tmux-plugins organization on GitHub holds tmux-sensible, tmux-resurrect, and tmux-continuum, which is where most people start with plugins.