tmux Cheat Sheet

tmux key bindings and commands for prefixes, sessions, windows, panes, copy mode, and configuration.

Editors & Tools
tmux
terminal
multiplexer

tmux keeps persistent terminal sessions and divides one terminal into reusable windows and panes. Unless noted otherwise, each shortcut below begins with the default prefix: press C-b (Ctrl-b), release it, and then press the command key.

Prefix and command mode

The prefix tells tmux that the next key belongs to tmux rather than the program running in the active pane. The command prompt accepts the same tmux commands used in ~/.tmux.conf or after the tmux shell command.

Table
KeysAction
C-b ?Display the current key bindings.
C-b :Open the tmux command prompt.
C-b C-bSend the prefix key to the active program.
C-b tShow a clock in the active pane.
text
C-b : new-window -n logs
C-b : display-message "session: #S, window: #I"

Sessions

A session owns its windows and survives client disconnection. Names are safer than numeric indexes in scripts and daily use.

bash
tmux new -s work
tmux ls
tmux attach -t work
tmux rename-session -t work release
tmux kill-session -t release
Table
KeysAction inside tmux
C-b dDetach this client while leaving the session running.
C-b sChoose from available sessions.
C-b $Rename the current session.

tmux attach -t work reconnects to an existing session; it does not create one. Use tmux new -As work when a shell workflow should attach if the session exists and create it otherwise.

Windows and panes

Windows are full terminal workspaces within a session. Panes split one window so several processes remain visible at once.

Table
KeysWindow action
C-b cCreate a window.
C-b ,Rename the current window.
C-b nSelect the next window.
C-b pSelect the previous window.
C-b &Confirm and kill the current window.
Table
KeysPane action
C-b %Split into side-by-side panes.
C-b "Split into stacked panes.
C-b oSelect the next pane.
C-b xConfirm and kill the active pane.
C-b zToggle zoom for the active pane.
C-b qBriefly display pane numbers.
C-b + arrowSelect the pane in that direction.

A window closes when its final pane exits. Zoom changes only the display; the other panes continue running.

Copy mode and scrollback

Copy mode pauses normal terminal input so tmux can navigate its history buffer. The selection keys depend on the configured editing style.

Table
Taskvi keysemacs keys
Enter copy modeC-b [C-b [
Begin selectionSpaceC-Space
Copy and leaveEnterM-w
Leave without copyingqq
Paste the latest tmux bufferC-b ]C-b ]

Choose a style explicitly in ~/.tmux.conf when consistent copy behavior matters:

conf
set-window-option -g mode-keys vi

With vi keys, move to the start of a region, press Space, extend the selection, and press Enter. The copied text goes to a tmux buffer, which is separate from the operating system clipboard unless clipboard integration is configured.

Configuration and custom bindings

The usual personal configuration path is ~/.tmux.conf. Global options use set-option -g; window options can use set-window-option -g; bind-key defines a key in the prefix table by default.

conf
set-option -g history-limit 50000
set-window-option -g mode-keys vi
bind-key r source-file ~/.tmux.conf \; display-message "configuration reloaded"
bind-key | split-window -h
bind-key - split-window -v

Reload changes without restarting the server:

bash
tmux source-file ~/.tmux.conf

A custom prefix needs both the new prefix and a binding that can pass it through to nested applications:

conf
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix

Mouse and status bar

Mouse mode enables pane selection, border resizing, window selection, and scroll-wheel access to copy mode in supporting terminals.

conf
set-option -g mouse on
set-option -g status on
set-option -g status-interval 5
set-option -g status-left "#S "
set-option -g status-right "%Y-%m-%d %H:%M"
Table
FormatExpands to
#SSession name.
#ICurrent window index.
#WCurrent window name.
#{pane_current_path}Active pane's working directory.

Set status-position top or status-position bottom to place the bar, and use status-left and status-right for compact session context. tmux expands #{...} formats itself, while date formats in the status line are passed through strftime-style expansion.

References