tmux Cheat Sheet
tmux key bindings and commands for prefixes, sessions, windows, panes, copy mode, and configuration.
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.
| Keys | Action |
|---|---|
C-b ? | Display the current key bindings. |
C-b : | Open the tmux command prompt. |
C-b C-b | Send the prefix key to the active program. |
C-b t | Show a clock in the active pane. |
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.
tmux new -s work
tmux ls
tmux attach -t work
tmux rename-session -t work release
tmux kill-session -t release
| Keys | Action inside tmux |
|---|---|
C-b d | Detach this client while leaving the session running. |
C-b s | Choose 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.
| Keys | Window action |
|---|---|
C-b c | Create a window. |
C-b , | Rename the current window. |
C-b n | Select the next window. |
C-b p | Select the previous window. |
C-b & | Confirm and kill the current window. |
| Keys | Pane action |
|---|---|
C-b % | Split into side-by-side panes. |
C-b " | Split into stacked panes. |
C-b o | Select the next pane. |
C-b x | Confirm and kill the active pane. |
C-b z | Toggle zoom for the active pane. |
C-b q | Briefly display pane numbers. |
C-b + arrow | Select 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.
| Task | vi keys | emacs keys |
|---|---|---|
| Enter copy mode | C-b [ | C-b [ |
| Begin selection | Space | C-Space |
| Copy and leave | Enter | M-w |
| Leave without copying | q | q |
| Paste the latest tmux buffer | C-b ] | C-b ] |
Choose a style explicitly in ~/.tmux.conf when consistent copy behavior matters:
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.
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:
tmux source-file ~/.tmux.conf
A custom prefix needs both the new prefix and a binding that can pass it through to nested applications:
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.
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"
| Format | Expands to |
|---|---|
#S | Session name. |
#I | Current window index. |
#W | Current 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.