tmux Cheatsheet
Configuration and Bindings
Use this tmux reference while you build software engineering projects, review code, or refresh the syntax you reach for most.
Where Config Lives
| Path | Scope |
|---|---|
~/.tmux.conf | Your user config (traditional location) |
~/.config/tmux/tmux.conf | XDG location, tmux 3.1+ |
/etc/tmux.conf | System wide |
tmux source-file ~/.tmux.conf # reload after editing tmux kill-server # nuclear reload
bind r source-file ~/.tmux.conf \; display "config reloaded"That reload binding is the first line worth adding, because you will edit the config a lot while getting it right.
set, setw, and Scope
| Command | Sets |
|---|---|
set -g option value | A global session option |
set option value | A session option for this session only |
setw -g option value | A global window option |
setw option value | A window option for this window |
set -p option value | A pane option (tmux 3.0+) |
set -a option value | Append to a string option |
set -u option | Unset, back to the default |
set -s option value | A server option |
tmux show-options -g # every global session option tmux show-options -gw # every global window option tmux show-options -s # server options tmux show-options -g status-style tmux list-keys # every binding tmux list-keys -T copy-mode-vi # bindings in one key table tmux lsk | grep resize
tmux show-options -g is how you find the real name of an option when a config snippet from the internet does not work on your version.
A Sensible tmux.conf
# Prefix unbind C-b set -g prefix C-a bind C-a send-prefix # Reload bind r source-file ~/.tmux.conf \; display "config reloaded" # Terminal set -g default-terminal "tmux-256color" set -ga terminal-overrides ",*256col*:Tc" # true color set -sg escape-time 10 # do not swallow Esc in Vim set -g focus-events on set -g history-limit 50000 # Indexing set -g base-index 1 setw -g pane-base-index 1 set -g renumber-windows on # Mouse and keys set -g mouse on setw -g mode-keys vi set -g status-keys vi # Splits that inherit the current directory bind '"' split-window -v -c "#{pane_current_path}" bind % split-window -h -c "#{pane_current_path}" bind c new-window -c "#{pane_current_path}" # Vim-style pane movement bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R # Repeatable resizing bind -r H resize-pane -L 5 bind -r J resize-pane -D 5 bind -r K resize-pane -U 5 bind -r L resize-pane -R 5 # Window movement bind -r C-h previous-window bind -r C-l next-window bind Tab last-window # Quality of life set -g display-time 2000 set -g display-panes-time 2000 setw -g monitor-activity on set -g visual-activity off set -g set-clipboard on
Options Worth Knowing
| Option | Does |
|---|---|
prefix | The prefix key |
default-terminal | $TERM inside tmux |
terminal-overrides | Per-terminal capability fixes (true color) |
escape-time | Delay after Esc before it is treated as a key |
history-limit | Scrollback lines per pane |
base-index, pane-base-index | Where numbering starts |
renumber-windows | Close gaps when a window is killed |
mouse | Mouse support |
mode-keys, status-keys | vi or emacs |
default-shell, default-command | Which shell panes start |
focus-events | Forward focus events to apps (Vim autoread) |
set-clipboard | Use OSC 52 for the system clipboard |
aggressive-resize | Resize to the smallest attached client per window |
monitor-activity, visual-activity | Activity flags and bells |
destroy-unattached | Kill sessions when the last client leaves |
detach-on-destroy | What happens when the current session dies |
allow-rename, automatic-rename | Whether programs may set window titles |
status, status-position, status-interval | Status bar on/off, top/bottom, refresh |
repeat-time | How long a -r binding stays repeatable |
escape-time 10 matters more than it looks: the default 500ms makes Vim feel broken inside tmux, because leaving Insert mode appears to hang.
Bindings
bind key command # bind in the prefix table bind -n key command # bind WITHOUT the prefix bind -r key command # repeatable bind -T copy-mode-vi key command # bind in a specific key table unbind key bind -N "description" k command # documented binding (tmux 3.1+)
# No-prefix bindings using Alt bind -n M-Left select-pane -L bind -n M-Right select-pane -R bind -n M-1 select-window -t 1 # Chain commands with \; bind X kill-pane \; display "pane killed" # Conditional: only send prefix through to Vim bind -n C-h if -F "#{@pane_is_vim}" 'send C-h' 'select-pane -L'