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

PathScope
~/.tmux.confYour user config (traditional location)
~/.config/tmux/tmux.confXDG location, tmux 3.1+
/etc/tmux.confSystem 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

CommandSets
set -g option valueA global session option
set option valueA session option for this session only
setw -g option valueA global window option
setw option valueA window option for this window
set -p option valueA pane option (tmux 3.0+)
set -a option valueAppend to a string option
set -u optionUnset, back to the default
set -s option valueA 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

OptionDoes
prefixThe prefix key
default-terminal$TERM inside tmux
terminal-overridesPer-terminal capability fixes (true color)
escape-timeDelay after Esc before it is treated as a key
history-limitScrollback lines per pane
base-index, pane-base-indexWhere numbering starts
renumber-windowsClose gaps when a window is killed
mouseMouse support
mode-keys, status-keysvi or emacs
default-shell, default-commandWhich shell panes start
focus-eventsForward focus events to apps (Vim autoread)
set-clipboardUse OSC 52 for the system clipboard
aggressive-resizeResize to the smallest attached client per window
monitor-activity, visual-activityActivity flags and bells
destroy-unattachedKill sessions when the last client leaves
detach-on-destroyWhat happens when the current session dies
allow-rename, automatic-renameWhether programs may set window titles
status, status-position, status-intervalStatus bar on/off, top/bottom, refresh
repeat-timeHow 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'