tmux Cheat Sheet
Every default tmux shortcut and the command behind it, from sessions and splits to floating panes, copy mode, the status bar and a tmux.conf that works on day one. Checked against the tmux 3.8 manual and source code; rows about newer features say which release added them.
By Bogdan SanduUpdated December 2, 2026Checked against tmux 3.8
tmux.conf builder
Pick the settings you want and copy a ready tmux.conf. Everything runs in your browser.
Workspace script builder
One line per window: a name, a colon, then the command to run. Add a second command after | to split the window. The script attaches to the session if it already exists.
Install & First Session
tmux is a terminal multiplexer: one terminal window holds many sessions, each session holds windows, and each window is split into panes. Sessions keep running on the server after you close the terminal or lose an SSH connection.
Install tmux
Install from your package manager
Distribution packages lag behind: Ubuntu 24.04 ships tmux 3.4 and Debian 13 ships 3.5a, while the current release is tmux 3.8. Floating panes, themes and switch mode need 3.7 or 3.8, so build from source or use Homebrew if you want them.
$ sudo apt install tmux # Debian, Ubuntu
$ sudo dnf install tmux # Fedora, RHEL
$ sudo pacman -S tmux # Arch
$ brew install tmux # macOS with HomebrewCheck which version you run
Prints the version, for example tmux 3.8. Many options and flags on this page say which version added them, so check this first when a config line fails.
$ tmux -VBuild the latest release from source
tmux needs only libevent and ncurses at runtime. make install puts the binary in /usr/local/bin, which comes before /usr/bin on most PATHs.
$ sudo apt install libevent-dev ncurses-dev build-essential bison pkg-config
$ curl -LO https://github.com/tmux/tmux/releases/download/3.8/tmux-3.8.tar.gz
$ tar xzf tmux-3.8.tar.gz && cd tmux-3.8
$ ./configure && make && sudo make installCommand line flags
| Flag | Does |
|---|---|
tmux -V | Print the version |
tmux -f file | Use another config file |
tmux -L name | Use a separate server with its own socket name |
tmux -S /path/to/socket | Use a server socket at that path |
tmux -2 | Assume the terminal supports 256 colours |
tmux -v | Write a debug log, -vv for more |
The first five minutes
Start, detach, list and come back
C-b d means: hold Ctrl, press b, release both, then press d. The session keeps running after you detach, including every program inside it.
$ tmux new -s work # start a session called work
# press C-b then d to detach
$ tmux ls # list sessions
$ tmux attach -t work # attach againAttach if the session exists, create it if not
-A makes new-session behave like attach-session when the name is taken. This is the line to put in a shell alias or an SSH command.
$ tmux new -A -s workThe keys you need on day one
| Keys | What they do |
|---|---|
C-b c | New window |
C-b % | Split the pane left and right |
C-b " | Split the pane top and bottom |
C-b arrow | Move to the pane in that direction |
C-b z | Zoom the pane to the full window and back |
C-b d | Detach and leave everything running |
C-b ? | List every key binding |
Prefix Key & Key Names
How tmux reads keys
Every default binding starts with the prefix
After the prefix, tmux waits for one more key. Keys marked repeatable, such as the pane resize keys, can be pressed again within repeat-time (500 ms) without the prefix.
| Notation | Meaning |
|---|---|
C-b | Ctrl and b, the default prefix |
M-x | Meta, usually Alt, and x |
S-Left | Shift and the left arrow |
C-b C-b | Send a literal C-b to the program in the pane |
PPage, NPage | Page Up and Page Down |
BTab | Shift and Tab |
DC | Delete |
Find out what a key does
| Keys or command | Result |
|---|---|
C-b ? | Browse all bindings with their notes |
C-b / then a key | Describe that one key |
tmux list-keys -N | Print bindings that have notes |
tmux list-keys -T copy-mode-vi | Print one key table |
Change the prefix
Use C-a like GNU Screen
send-prefix makes C-a C-a send a real C-a, so beginning of line still works in the shell. C-a clashes with that shell shortcut and with Vim's increment, which is why many people pick C-Space or C-s instead.
unbind C-b
set -g prefix C-a
bind C-a send-prefixKeep C-b and add a second prefix
prefix2 adds an extra prefix without removing the first, handy when your hands know both.
set -g prefix2 C-SpaceSessions
Manage sessions from the shell
Create sessions
$ tmux # unnamed session, named 0, 1, 2...
$ tmux new -s api # named session
$ tmux new -s api -n editor # name the first window too
$ tmux new -s api -c ~/code/api # start in a directory
$ tmux new -d -s logs 'tail -f /var/log/syslog' # detached, running a commandAttach, list and kill
tmux ls prints one line per session with its window count, creation time and (attached) when a client is on it.
$ tmux ls # list sessions
$ tmux attach # attach to the most recent session
$ tmux attach -t api # attach to one session
$ tmux attach -d -t api # attach and detach every other client
$ tmux kill-session -t api # kill one session
$ tmux kill-session -a -t api # kill every session except api
$ tmux kill-server # stop tmux and every sessionCheck if a session exists in a script
has-session exits with 0 when the target exists and 1 when it does not, so it works in if and && chains.
$ tmux has-session -t api 2>/dev/null && echo runningSession keys
Inside tmux
In the tree from C-b s, Enter switches, + and - expand and collapse an item, x kills it, t tags it, C-s searches by name and f filters with a format.
| Keys | Action |
|---|---|
C-b d | Detach the current client |
C-b D | Choose a client to detach |
C-b s | Pick a session from a tree |
C-b $ | Rename the session |
C-b ( and C-b ) | Previous and next session |
C-b L | Last session you used |
C-b S-Tab | Fuzzy session switcher (3.8) |
Switch from the command prompt
Type these after C-b :. Every tmux command can be run from that prompt, from a shell with tmux in front, or from tmux.conf.
switch-client -t api
rename-session workWindows
Window keys
Create, move between and close windows
| Keys | Action |
|---|---|
C-b c | New window |
C-b n and C-b p | Next and previous window |
C-b l | Last window you were in |
C-b 0 to C-b 9 | Window 0 to 9 |
C-b ' | Prompt for a window index |
C-b w | Pick a window from a tree |
C-b Tab | Fuzzy window switcher (3.8) |
C-b , | Rename the window |
C-b . | Move the window to another index |
C-b f | Find a window by its text |
C-b & | Kill the window, after a y/n prompt |
C-b M-n and C-b M-p | Next and previous window with an alert |
Window commands
Create windows with a name, directory or command
-c "#{pane_current_path}" opens the window in the directory of the current pane instead of the session's start directory. Run it from a key binding so the format is expanded.
$ tmux new-window -n logs
$ tmux new-window -c "#{pane_current_path}"
$ tmux new-window -t api: -n db 'psql app'Reorder windows
swap-window -t 0 swaps the current window with window 0. move-window -r renumbers every window in the session so there are no gaps.
swap-window -t 0
move-window -t 5
move-window -rStop tmux renaming your windows
automatic-rename names a window after the program running in it and is on by default; renaming a window with C-b , also turns it off for that window. allow-rename, off by default, lets programs rename windows with an escape sequence.
setw -g automatic-rename off
set -g allow-rename offNumber windows from 1 and close the gaps
With base-index 1, C-b 1 is the first window, which matches the keyboard. renumber-windows closes the gap when a window in the middle is killed.
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows onPanes & Splits
Pane keys
Split, move and close
| Keys | Action |
|---|---|
C-b % | Split left and right |
C-b " | Split top and bottom |
C-b arrow | Go to the pane in that direction |
C-b o | Next pane |
C-b ; | Last active pane |
C-b q | Show pane numbers, type one to jump |
C-b z | Zoom or unzoom the pane |
C-b x | Kill the pane, after a y/n prompt |
C-b ! | Break the pane out into its own window |
C-b { and C-b } | Swap with the previous or next pane |
C-b C-o and C-b M-o | Rotate panes forward and backward |
C-b T | Set the pane title (3.8) |
Resize from the keyboard
Repeatable keys accept further presses without the prefix for 500 ms, so C-b M-Up M-Up M-Up grows a pane by 15 lines.
| Keys | Action |
|---|---|
C-b C- arrow | Resize by 1 cell, repeatable |
C-b M- arrow | Resize by 5 cells, repeatable |
C-b E | Spread panes out evenly |
Pane commands
Split with a size, side or directory
-h puts the new pane to the right, -v below. -l takes cells or a percentage, -b puts the new pane on the left or above, and -f spans the full window instead of splitting the current pane.
split-window -h -l 30%
split-window -v -l 10
split-window -hb
split-window -fv
split-window -h -c "#{pane_current_path}"Resize to an exact size
-U, -D, -L, -R move the border by a number of cells; -x and -y set an absolute width or height; -Z toggles zoom.
resize-pane -D 5
resize-pane -x 80
resize-pane -y 30%
resize-pane -ZMove panes between windows
join-pane -s 2 -t 1 takes the active pane of window 2 and splits it into window 1. Targets are written session:window.pane.
break-pane -d
join-pane -s 2 -t 1
join-pane -h -s :3.1
swap-pane -s 1 -t 2Mark a pane, then use it as a target
| Keys or command | Action |
|---|---|
C-b m | Mark or unmark the active pane |
C-b M | Clear the mark |
join-pane | With no -s, joins the marked pane here |
swap-pane | With no -s, swaps with the marked pane |
Close every pane except the current one
kill-pane -a keeps only the active pane in the window; kill-window -a keeps only the current window in the session. Neither asks for confirmation.
kill-pane -a
kill-window -aRestart the program in a pane
respawn-pane -k kills whatever runs in the pane and starts its original command again. With remain-on-exit on, a pane stays open after its program exits, so you can read the last output and respawn it.
respawn-pane -k
setw -g remain-on-exit onName panes and show the names on the borders
select-pane -T "api server"
set -g pane-border-status top
set -g pane-border-format " #P #{pane_title} "Floating Panes
Floating panes, added in tmux 3.7 and extended in 3.8, sit above the tiled layout like small windows. Unlike a popup they are real panes: you can switch to them, resize them, move them and turn them back into tiled panes.
Floating pane keys
Create and switch between floating and tiled
| Keys | Action |
|---|---|
C-b * | New floating pane |
C-b @ | Float a tiled pane, or tile a floating one |
C-b g then a key | Move the floating pane |
C-b M- arrow | Resize it, as for tiled panes |
| Ctrl and drag | Draw a new floating pane with the mouse |
Move keys after C-b g
| Key | Moves the floating pane to |
|---|---|
1 2 3 4 | Top left, top right, bottom left, bottom right corner |
M-1 to M-4 | That corner, resized to a quarter of the window |
| Arrow | The middle of that edge |
M- arrow | That half of the window |
0 | Fill the whole window |
, | A menu of positions |
new-pane
Open a floating pane with a size and position
-x and -y set the width and height, -X and -Y the top left corner, each in cells or a percentage. Without a size the pane is half the window wide and a quarter high, cascaded from the top left.
new-pane
new-pane -x 60% -y 40% -X 20% -Y 10%
new-pane -c "#{pane_current_path}" htop
new-pane -T notes -B double 'vim ~/notes.md'Modal pane that blocks the others until it closes
-O makes the pane modal: it stays active and the other panes ignore input while it is open. -D closes it with Escape or C-c, -C closes it when you click outside, and -K sends every key, the prefix too, to the pane.
new-pane -O -D -x 70% -y 60% 'lazygit'Wait for a command in a floating pane from a script
-W blocks until the command in the pane exits and returns its exit status, so a script can open an editor in a floating pane and continue afterwards.
$ tmux new-pane -W 'vi /tmp/message.txt'
$ echo $?Layouts
Preset layouts
Switch layouts with the keyboard
| Keys | Layout |
|---|---|
C-b Space | Next layout |
C-b M-1 | even-horizontal: side by side |
C-b M-2 | even-vertical: stacked |
C-b M-3 | main-horizontal: big pane on top |
C-b M-4 | main-vertical: big pane on the left |
C-b M-5 | tiled: a grid |
C-b M-6 | main-horizontal-mirrored: big pane at the bottom |
C-b M-7 | main-vertical-mirrored: big pane on the right |
Set a layout and the size of the main pane
main-pane-width and main-pane-height accept cells or a percentage. select-layout -E spreads the current pane and its neighbours out evenly, the same as C-b E.
select-layout main-vertical
setw -g main-pane-width 60%
select-layout -ESave and restore the exact layout
window_layout holds the layout string of the window. Paste it back with select-layout to rebuild the same split. In tmux 3.8 the string is a JSON subset that includes floating panes; the old format is still accepted.
$ tmux display -p '#{window_layout}'
$ tmux select-layout 'LAYOUT STRING'Copy Mode & Scrollback
Copy mode freezes the pane so you can scroll back through its history, search it and select text. By default the keys follow Emacs; set mode-keys to vi for Vim keys.
Enter and leave copy mode
Scroll back through output
| Keys | Action |
|---|---|
C-b [ | Enter copy mode |
C-b PgUp | Enter copy mode and scroll up a page |
| Mouse wheel | Enter copy mode and scroll, with the mouse option on |
q | Leave copy mode |
Keep more history per pane
The default is 2000 lines per pane. Since tmux 3.7 a changed limit also applies to panes that already exist, not only to new ones.
set -g history-limit 50000Emacs keys (the default)
Move, search, select and copy
Jumping between prompts needs a shell that marks its prompts with OSC 133 escape sequences, which recent versions of fish, zsh and bash with a prompt framework can emit.
| Keys | Action |
|---|---|
C-Space | Start a selection |
M-w or C-w | Copy the selection and leave copy mode |
C-g | Clear the selection |
R | Toggle rectangle selection |
C-s and C-r | Search down and up |
n and N | Next and previous match |
M-< and M-> | Top and bottom of the history |
C-v and M-v | Page down and up |
g | Go to a line |
L | Toggle line numbers |
C-M-Up and C-M-Down | Previous and next shell prompt |
Vi Copy Mode
Switch copy mode to Vim keys
Turn on vi keys and make v and y behave like Vim
Out of the box, vi copy mode starts a selection with Space, copies with Enter, and binds v to rectangle-toggle. These three lines give you Vim's v, y and C-v.
setw -g mode-keys vi
bind -T copy-mode-vi v send -X begin-selection
bind -T copy-mode-vi y send -X copy-selection-and-cancel
bind -T copy-mode-vi C-v send -X rectangle-toggleDefault vi copy mode keys
Movement
| Keys | Action |
|---|---|
h j k l | Left, down, up, right |
w b e | Next word, previous word, end of word |
0 ^ $ | Start of line, first non-blank, end of line |
g and G | Top and bottom of the history |
H M L | Top, middle and bottom of the screen |
C-u and C-d | Half a page up and down |
C-b and C-f | A page up and down |
{ and } | Previous and next paragraph |
% | Matching bracket |
f F t T | Jump to a character, like Vim |
: | Go to a line |
Search, select and copy
| Keys | Action |
|---|---|
/ and ? | Search down and up |
n and N | Next and previous match |
* and # | Search for the word under the cursor |
Space | Start a selection |
V | Select the whole line |
v | Toggle rectangle selection |
o | Jump to the other end of the selection |
Enter | Copy the selection and leave |
A | Append the selection to the last buffer and leave |
D | Copy to the end of the line and leave |
Escape | Clear the selection |
q | Leave copy mode |
System Clipboard
Copy into the system clipboard
OSC 52: works locally and over SSH
tmux sends copied text to the terminal with the OSC 52 escape sequence, and the terminal puts it on the clipboard. This works through SSH, with no tool on the server. The default, external, already sets the terminal clipboard but ignores programs inside tmux that try to; on also accepts them, which Neovim and other editors need.
set -s set-clipboard onPipe copies to a clipboard program instead
Pick the line for your system: pbcopy on macOS, wl-copy on Wayland, xclip on X11. The copy-pipe commands, which Enter and the mouse drag use, run copy-command when they get no command of their own.
set -s copy-command 'pbcopy'
set -s copy-command 'wl-copy'
set -s copy-command 'xclip -selection clipboard -in'Copy straight to the clipboard from vi mode
copy-pipe-and-cancel puts the selection in a tmux buffer, pipes it to the command and leaves copy mode.
bind -T copy-mode-vi y send -X copy-pipe-and-cancel 'pbcopy'Paste Buffers
Work with paste buffers
Paste and pick earlier copies
Every copy creates a new buffer and tmux keeps the 50 most recent, set by buffer-limit. In the C-b = list, Enter pastes, d deletes and e opens the buffer in an editor.
| Keys | Action |
|---|---|
C-b ] | Paste the most recent buffer |
C-b = | Choose a buffer from a list, with a preview |
C-b # | List buffers |
C-b - | Delete the most recent buffer |
Move text between tmux and files
$ tmux show-buffer # print the newest buffer
$ tmux save-buffer ~/copied.txt # newest buffer to a file
$ tmux load-buffer ~/snippet.txt # file to a new buffer
$ tmux set-buffer "kubectl get pods -A" # text to a new buffer
$ echo hello | tmux load-buffer - # stdin to a new bufferPaste into another pane from a script
$ tmux paste-buffer -t api:1.2Mouse
Mouse support
Mouse is on by default from tmux 3.8
In tmux 3.8 the mouse option defaults to on. On earlier versions add set -g mouse on to tmux.conf. With it on you can click a pane to select it, drag borders to resize, scroll with the wheel, click a window name in the status line and drag to select text.
set -g mouse on
set -g mouse offSelect text the terminal way while the mouse is on
Holding the modifier sends the drag to the terminal instead of tmux, so you get the terminal's own selection and copy.
| Terminal | Hold while dragging |
|---|---|
| Most Linux terminals | Shift |
| iTerm2 | Option |
| Windows Terminal | Shift |
Select the pane under the mouse without clicking
set -g focus-follows-mouse onDrag-select copies right away
This binding keeps the selection on screen after the copy instead of leaving copy mode.
bind -T copy-mode-vi MouseDragEnd1Pane send -X copy-selection-no-cleartmux.conf Essentials
The config file
Where tmux looks for it
tmux reads the config only when the server starts. Edits do nothing until you reload the file or run tmux kill-server and start again.
| Path | Used for |
|---|---|
~/.tmux.conf | Your config |
$XDG_CONFIG_HOME/tmux/tmux.conf | Your config, XDG style |
~/.config/tmux/tmux.conf | Your config, XDG style |
/etc/tmux.conf | System-wide config, read first |
Reload the config without restarting
C-b r is already taken by refresh-client, so this uses capital R. The \; chains a second command on the same binding.
bind R source-file ~/.tmux.conf \; display "config reloaded"Test a config without touching your sessions
-L starts a second, separate server, so a broken test config cannot affect the sessions you are working in. -f /dev/null starts with no config at all, which is the quickest way to tell whether a problem comes from your config.
$ tmux -L test -f ~/.tmux.new.conf new
$ tmux -f /dev/null -L clean newA sensible starter config
Everyday defaults most people change
tmux-256color gives programs the right colour and italic support; the terminal-features line enables 24-bit colour when the outer terminal is xterm-256color. An escape-time of 10 ms, the default since tmux 3.5, removes the delay after Escape in Vim. focus-events lets Vim and Neovim notice when you switch panes.
set -g default-terminal "tmux-256color"
set -as terminal-features ",xterm-256color:RGB"
set -s escape-time 10
set -g history-limit 50000
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on
set -g focus-events on
setw -g mode-keys vi
set -s set-clipboard onSplit and open windows in the current directory
| and - look like the split they make. Rebinding - replaces the default delete-buffer key.
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"
bind c new-window -c "#{pane_current_path}"Move between panes with h j k l
This replaces C-b l, the default last-window key, and C-b L, last session. -r makes the resize keys repeatable.
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
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 5Key Bindings
bind and unbind
The shapes of a binding
Plain bind adds to the prefix table. -n binds in the root table, so the key works without the prefix. -r makes it repeatable, -T picks a key table, and -N adds a note that shows in C-b ?.
bind x kill-pane
bind -n M-Left select-pane -L
bind -r Up resize-pane -U
bind -T copy-mode-vi y send -X copy-selection-and-cancel
bind -N "Open lazygit" G new-pane -x 90% -y 90% lazygit
unbind C-zKey tables you can bind in
| Table | Active when |
|---|---|
prefix | After the prefix key |
root | Always, no prefix |
copy-mode | Copy mode with Emacs keys |
copy-mode-vi | Copy mode with vi keys |
move | After C-b g, for floating panes (3.8) |
| Any name | After switch-client -T name |
Chain several commands on one key
Braces group commands and are easier to read than \; separators. Formats like #{pane_index} inside run-shell are expanded before the shell runs.
bind S { split-window -h; split-window -v; select-layout main-vertical }
bind P run-shell "tmux capture-pane -p -S - > ~/pane-#{pane_index}.txt"Make a mode of your own with a key table
After C-b w, the next key is looked up in window-keys. Note that this replaces the default C-b w window chooser.
bind w switch-client -T window-keys
bind -T window-keys c new-window
bind -T window-keys k kill-window
bind -T window-keys r command-prompt -I "#W" "rename-window '%%'"Options & Scopes
set-option
Set an option at the right scope
tmux usually works out the scope from the option name, so set -g mode-keys vi also works. setw is the old spelling of set -w and is still accepted.
| Command | Scope |
|---|---|
set -s escape-time 10 | Server: one value for everything |
set -g status-style bg=black | Session: the global default for all sessions |
set status-style bg=red | Session: only the current session |
setw -g mode-keys vi | Window: the global default for all windows |
set -p window-style bg=colour235 | Pane: only the current pane |
Change, append, unset and query
-a appends to a string option, -u unsets so the global value applies again, -o refuses to overwrite an option that is already set, and -q suppresses errors for unknown options, so a config that sets focus-follows-mouse, new in 3.7, still loads on older tmux. show -v prints only the value.
set -ga terminal-overrides ",*256col*:Tc"
set -u status-style
set -o monitor-activity on
set -q -g focus-follows-mouse on
show -g mouse
show -gv history-limitYour own options for scripts and formats
Options starting with @ are user options. Plugins use them for settings, and you can read them in any format.
set -g @project "billing-api"
display "#{@project}"Status Bar
Change the status line
Move it, refresh it, colour it
status-interval is in seconds; the default is 15. bg=default lets the terminal background show through, which suits both light and dark terminal themes.
set -g status-position top
set -g status-interval 5
set -g status-style "bg=default,fg=colour250"
set -g status-justify centreLeft and right parts
status-left is cut to status-left-length, 10 cells by default, so long session names need a bigger value. %a %d %b %H:%M are strftime codes for day, date, month and time. #{?client_prefix,PREFIX ,} shows PREFIX while tmux is waiting for the key after the prefix.
set -g status-left "#[bold] #S #[nobold]"
set -g status-left-length 30
set -g status-right "#{?client_prefix,PREFIX ,}#H %a %d %b %H:%M "Window list formats
The current window gets its own format. window_zoomed_flag is 1 when a pane in the window is zoomed, so the Z marks zoomed windows.
setw -g window-status-format " #I:#W "
setw -g window-status-current-format "#[reverse] #I:#W#{?window_zoomed_flag, Z,} #[noreverse]"
setw -g window-status-separator ""Two status lines, or none
status accepts on, off or a number of lines from 2 to 5. The extra lines use the status-format array; tmux 3.6 added useful defaults for the second and third lines.
set -g status 2
set -g status offDefault contents
| Option | Default |
|---|---|
status-left | [#{session_name}] |
status-left-length | 10 |
status-right-length | 40 |
window-status-format | #I:#W#{?window_flags,#{window_flags}, } |
status-interval | 15 |
Formats & Variables
Format strings
Print any value with display-message
display -p prints to stdout instead of the status line, which makes formats the quickest way to read tmux state from a script.
$ tmux display -p '#{session_name}:#{window_index}.#{pane_index}'
$ tmux display -p '#{pane_current_path}'
$ tmux display -p '#{pane_current_command}'One-letter aliases
| Alias | Variable | Value |
|---|---|---|
#S | session_name | Session name |
#I | window_index | Window index |
#W | window_name | Window name |
#F | window_flags | Window flags such as * for current and Z for zoomed |
#P | pane_index | Pane index |
#D | pane_id | Unique pane ID such as %3 |
#T | pane_title | Pane title |
#H | host | Hostname |
#h | host_short | Hostname without the domain |
List panes in your own format
-a lists every pane on the server. -F takes any format, so the output is easy to parse with awk or cut.
$ tmux list-panes -a -F '#{session_name}:#{window_index}.#{pane_index} #{pane_current_command} #{pane_current_path}'
$ tmux list-windows -F '#I #W #{window_panes} panes'
$ tmux list-sessions -F '#S #{session_windows} windows #{?session_attached,attached,}'Format modifiers
Conditions and comparisons
| Format | Result |
|---|---|
#{?session_attached,yes,no} | yes if the session is attached |
#{==:#{host},myhost} | 1 if the host is myhost |
#{!=:#{window_panes},1} | 1 if the window has more than one pane |
#{&&:#{pane_in_mode},#{window_zoomed_flag}} | 1 if both are true |
#{m:*vim*,#{pane_current_command}} | 1 if the glob matches |
Transform values
| Format | Result |
|---|---|
#{=20:pane_title} | First 20 characters |
#{=-20:pane_title} | Last 20 characters |
#{b:pane_current_path} | Basename of the path |
#{d:pane_current_path} | Directory part of the path |
#{s/foo/bar/:window_name} | Replace with a regular expression |
#{t:window_activity} | Timestamp as a readable date |
#{n:window_name} | Length of the value |
#{e|+|:#{window_index},1} | Arithmetic |
#{E:status-left} | Expand the format inside an option |
#{T:status-left} | Expand it, strftime codes too |
#{l:#{pane_id}} | Literal text, not expanded |
Run a shell command in a format
#() inserts the last line the command prints. tmux never waits for it: the status line shows the previous result until the new one is ready, and runs the command again on each status-interval.
set -g status-right "#(cut -d' ' -f1-3 /proc/loadavg) %H:%M"Colours, Styles & Themes
Styles
Style syntax
| Style | Meaning |
|---|---|
fg=red,bg=black | Foreground and background colour |
fg=colour208 | One of the 256 colours |
fg=#ff8700 | 24-bit hex colour |
bg=default | The terminal's own background |
bold, italics, reverse, dim | Attributes; prefix with no to turn off |
#[fg=green]text#[default] | Inline style inside a format |
Colour borders and the active pane
window-style and window-active-style dim the text of inactive panes so the active one stands out. terminal means the terminal's default colour.
set -g pane-border-style "fg=colour238"
set -g pane-active-border-style "fg=colour39"
set -g window-style "fg=colour245"
set -g window-active-style "fg=terminal"Find out if 24-bit colour works
The list should include RGB. If it does not, add set -as terminal-features ",xterm-256color:RGB" with your outer TERM in place of xterm-256color, then detach and attach again.
$ tmux display -p '#{client_termfeatures}'Built-in themes
Light and dark themes that follow the terminal
tmux 3.8 ships light and dark colour themes for terminals with 256 or more colours. detect, the default, asks the terminal whether it is light or dark; terminal restores the old behaviour of using the terminal's ANSI colours.
set -g theme detect
set -g theme dark
set -g theme terminalUse theme colours in your own styles
Theme colour names such as themegreen and themeblack resolve to the light or dark palette in use. The dark-theme-* and light-theme-* options change what each name means.
set -g status-style "bg=themegreen,fg=themeblack"
set -g dark-theme-green "#2f6f4f"Scripting tmux
Build a workspace from a script
Create a session with windows, splits and commands
-d creates everything detached, send-keys ... Enter types a command and presses Enter, and the last line attaches. Run it a second time and it attaches to the session that already exists. The .2 target assumes pane-base-index 1.
#!/bin/sh
S=shop
tmux has-session -t "$S" 2>/dev/null && exec tmux attach -t "$S"
tmux new-session -d -s "$S" -n code -c ~/code/shop
tmux send-keys -t "$S:code" 'nvim .' Enter
tmux new-window -t "$S" -n run -c ~/code/shop
tmux send-keys -t "$S:run" 'npm run dev' Enter
tmux split-window -t "$S:run" -h -c ~/code/shop
tmux send-keys -t "$S:run.2" 'npm test -- --watch' Enter
tmux select-window -t "$S:code"
exec tmux attach -t "$S"Targets
| Target | Means |
|---|---|
api | Session api |
api:2 | Window 2 in session api |
api:logs | The window named logs |
api:2.1 | Pane 1 in window 2 |
%7 | Pane with ID %7, stable for its whole life |
{last}, {next} | Last or next window or pane |
{marked} | The marked pane |
Read from and wait on panes
Capture what a pane shows
-S - starts at the top of the history and negative numbers count back into it. pipe-pane with -o toggles: run it again to stop logging.
$ tmux capture-pane -p -t api:1 # visible screen to stdout
$ tmux capture-pane -p -S - -t api:1 > log # whole history to a file
$ tmux capture-pane -p -S -100 -E -1 # the last 100 lines of history
$ tmux pipe-pane -o 'cat >> ~/pane.log' # keep logging new outputWait until a job in another pane finishes
wait-for blocks on a named channel until something calls wait-for -S with the same name.
$ tmux send-keys -t build 'make; tmux wait-for -S built' Enter
$ tmux wait-for built && echo "build done"Run shell commands from tmux
if-shell runs the first command when the shell test succeeds; -F tests a format instead of running a shell, which is faster.
run-shell "git -C #{pane_current_path} pull"
if-shell "test -f ~/.tmux.local" "source-file ~/.tmux.local"
if-shell -F "#{==:#{session_name},prod}" "set status-style bg=red"Popups & Menus
Popups
Open a command in a popup over the panes
-E closes the popup when the command exits; -EE closes it only on success. With no command you get your shell. A popup is not a pane: it disappears when it closes and cannot be moved into the layout, which floating panes can.
bind C-g display-popup -E -w 90% -h 90% -d "#{pane_current_path}" lazygit
bind C-t display-popup -E -w 80% -h 60%A popup that picks a session with fzf
bind C-j display-popup -E "tmux list-sessions -F '#S' | fzf --reverse | xargs tmux switch-client -t"Menus
Built-in and custom menus
Each item is a name, a shortcut key and a command. This replaces the default C-b m mark-pane key.
bind m display-menu -T "Layout" \
"Even horizontal" h "select-layout even-horizontal" \
"Even vertical" v "select-layout even-vertical" \
"Tiled" t "select-layout tiled"Hooks & Events
Run commands when something happens
Common hooks
Every command has an after- hook, such as after-new-window. Other hooks fire on events: session-created, client-attached, pane-exited and pane-died, alert-activity and many more. show-hooks -g lists what is set.
set-hook -g session-created 'display "new session #{session_name}"'
set-hook -g after-split-window 'select-layout -E'
set-hook -g client-attached 'run-shell "notify-send attached"'
set-hook -g pane-died 'display "pane #{pane_index} exited"'React to shell commands finishing
With a shell that sends OSC 133 marks, tmux 3.8 fires pane-command-started, pane-command-finished and pane-shell-prompt events, and pane_command_status holds the exit status.
set-hook -g pane-command-finished 'if -F "#{!=:#{pane_command_status},0}" "display \"command failed in #{pane_index}\""'Hook commands added in tmux 3.8
Monitor hook names start with @, and the what part takes the same targets as refresh-client -B: a pane ID, %* for all panes, a window ID or @* for all windows.
| Command | Does |
|---|---|
set-hook -B name:what:format | Monitor hook: checks a format every second and runs when the value changes |
set-hook -T | With -B, run only while the format is true |
set-hook -E @event | Fire a user event right away |
wait-for -E | Block until a hook, notification or user event fires |
show-hooks -B | List monitor hooks |
Synchronize Panes
Type into every pane at once
Toggle broadcast for the current window
With synchronize-panes on, keys typed in one pane go to every pane in the window that is not in a mode. Typical use: one SSH session per server, then run the same command on all of them.
bind y setw synchronize-panes \; display "sync #{?synchronize-panes,on,off}"Send one command to every pane from a script
-s lists the panes of every window in the session. Pane IDs such as %4 stay valid even if panes move or are renumbered.
$ for p in $(tmux list-panes -s -F '#{pane_id}'); do tmux send-keys -t "$p" 'uptime' Enter; donePlugins (TPM)
tmux Plugin Manager
Install TPM
$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpmList plugins at the bottom of tmux.conf
The run line must stay the last line of the file. Reload the config, then press C-b I to install the plugins.
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @continuum-restore 'on'
run '~/.tmux/plugins/tpm/tpm'TPM and resurrect keys
tmux-continuum saves every 15 minutes and, with @continuum-restore on, restores the last save when the tmux server starts. Saved state covers sessions, windows, layouts and working directories; running programs are restarted only for a short allow-list.
| Keys | Action |
|---|---|
C-b I | Install the plugins listed in tmux.conf |
C-b U | Update plugins |
C-b M-u | Remove plugins no longer listed |
C-b C-s | Save sessions, with tmux-resurrect |
C-b C-r | Restore sessions, with tmux-resurrect |
SSH, Nesting & Sharing
tmux over SSH
Reconnect to the same session every time
-t gives the remote side a terminal. If the connection drops, run the same line again and you land in the same session with everything still running.
$ ssh -t prod 'tmux new -A -s main'Control tmux inside tmux
C-b C-b runs send-prefix, so the inner tmux sees a prefix and takes the next key. Many people give the inner tmux, often on a server, a different prefix and status colour.
| Keys | Goes to |
|---|---|
C-b c | The outer tmux |
C-b C-b c | The inner tmux |
Share a session
Pair on one machine through a shared socket
-S puts the server socket at a path you choose. Since tmux 3.3 other users also need to be allowed with server-access -a username, run from inside the session.
$ tmux -S /tmp/pair new -s pair
$ chmod 770 /tmp/pair && chgrp devs /tmp/pair
$ tmux -S /tmp/pair attach -t pair # run by the second userGrouped sessions: same windows, separate views
A session created with -t shares the windows of the target but keeps its own current window, so two people can look at different windows.
$ tmux new -t pair -s pair-viewRead-only clients and separate servers
-r attaches read-only, so keys are ignored. -L names a separate server socket, which gives you an independent tmux with its own sessions and options.
$ tmux attach -r -t pair
$ tmux -L work new -s mailTroubleshooting
Common problems
Error messages and what they mean
| Message | Fix |
|---|---|
sessions should be nested with care, unset $TMUX to force | You ran tmux inside tmux. Use a new window, or env -u TMUX tmux if you really want nesting |
no server running on /tmp/tmux-1000/default | No session exists yet; start one with tmux new |
can't find session: api | Check the name with tmux ls |
invalid option: ... | The option is newer than your tmux; check tmux -V |
/home/me/.tmux.conf:12: unknown command: ... | The command does not exist in your version |
Colours look wrong in Vim or Neovim
Then exit tmux completely with tmux kill-server, because the server reads these only when it starts. In Neovim, :checkhealth reports tmux settings that need attention.
set -g default-terminal "tmux-256color"
set -as terminal-features ",xterm-256color:RGB"See messages and debug output
| Keys or command | Shows |
|---|---|
C-b ~ | Recent messages, including config errors |
tmux show -g | Every global session option |
tmux show -s | Every server option |
tmux -vv new | Writes debug logs to tmux-server-PID.log in the current directory |
tmux source-file -v ~/.tmux.conf | Each command as it loads |
Config changes do nothing
The server reads the config once. Reload with tmux source-file ~/.tmux.conf, but options that only apply on creation, such as default-terminal, need new sessions or a full tmux kill-server.
$ tmux source-file ~/.tmux.conftmux 3.4 to 3.8
What changed in recent releases
Release history
Patch releases such as 3.7a to 3.7c and 3.6a and 3.6b only fix bugs. The full list is in the CHANGES file in the tmux repository.
| Version | Released | Highlights |
|---|---|---|
| 3.8 | September 9, 2026 | Modal floating panes, built-in light and dark themes, switch mode on C-b Tab and C-b S-Tab, mouse on by default, monitor hooks, OSC 133 events, C-b T pane title |
| 3.7 | June 26, 2026 | Floating panes, new-pane, line numbers in copy mode, focus-follows-mouse, history-limit changes apply to existing panes |
| 3.6 | November 26, 2025 | Better second and third status lines, light and dark theme reporting to applications, case-insensitive search in modes |
| 3.5 | September 27, 2024 | escape-time default down to 10 ms, mirrored main layouts, prefix-timeout option |
| 3.4 | February 13, 2024 | The version in Ubuntu 24.04 |
Nothing matches. Try a single word.
What Is a tmux Cheat Sheet
A tmux cheat sheet is a short reference to the key bindings, commands and options of tmux, the terminal multiplexer, laid out so you can find the shortcut for a split, the flag for a popup or the line for your tmux.conf without reading the whole manual. People also search for tmux shortcuts, tmux commands or tmux keybindings; they mean the same thing, usually while setting up a new machine or working on a server over SSH.
This one has 26 sections and 109 rows, written for tmux 3.8 and still useful on the tmux 3.4 that Ubuntu 24.04 ships. Every default key binding was taken from the key-bindings.c file in the tmux 3.8 source, and every command and flag on the page was checked against the tmux 3.8 manual page by a script, so a key that moved or a flag that does not exist would have been caught. Rows about features from tmux 3.6, 3.7 or 3.8 name the version, which matters because distribution packages are often two or three releases behind.
How It Differs From the Manual
The tmux manual is complete and very long: it lists every option in alphabetical order inside each scope, which is the right order for looking something up you already know exists. This page is ordered by task instead: start a session, split it, scroll back, copy text, make it look the way you want, script it. Use the search box above to jump to a key or a command, and the two builders near the top to write a tmux.conf or a workspace script without typing it by hand.
What This tmux Cheat Sheet Covers
- Getting started: installing tmux and the first session, and the prefix key and key names.
- Workspaces: sessions, windows, panes and splits, floating and modal panes and layouts.
- Scrollback and copy: copy mode, vi copy mode, the system clipboard, paste buffers and the mouse.
- Configuration: tmux.conf essentials, key bindings, options and scopes, the status bar, formats and colours and themes.
- Automation: scripting tmux, popups and menus, hooks, synchronized panes, plugins and SSH, nesting and sharing.
- Help: troubleshooting and what changed from tmux 3.4 to 3.8.
tmux Shortcuts Quick Reference
The thirty bindings most people use every day. Each one starts with the prefix, C-b, unless you changed it.
| Task | Keys |
|---|---|
| Detach from the session | C-b d |
| Pick a session | C-b s |
| Rename the session | C-b $ |
| New window | C-b c |
| Next and previous window | C-b n, C-b p |
| Go to window 3 | C-b 3 |
| Last window | C-b l |
| Rename the window | C-b , |
| Pick a window | C-b w |
| Kill the window | C-b & |
| Split left and right | C-b % |
| Split top and bottom | C-b " |
| Move between panes | C-b and an arrow |
| Show pane numbers | C-b q |
| Zoom a pane | C-b z |
| Kill the pane | C-b x |
| Pane to its own window | C-b ! |
| Resize a pane | C-b C- or C-b M- and an arrow |
| Next layout | C-b Space |
| New floating pane (3.8) | C-b * |
| Float or tile a pane (3.8) | C-b @ |
| Enter copy mode | C-b [ |
| Paste | C-b ] |
| Choose a paste buffer | C-b = |
| Command prompt | C-b : |
| List all bindings | C-b ? |
| Describe one key | C-b / |
| Show recent messages | C-b ~ |
| Fuzzy window switcher (3.8) | C-b Tab |
| Fuzzy session switcher (3.8) | C-b S-Tab |
What tmux Is
tmux is a terminal multiplexer: a program that runs many terminal sessions inside one terminal window and keeps them alive on the machine when you close that window. Nicholas Marriott started it in 2007 as a modern replacement for GNU Screen, and it is developed in the open on the tmux GitHub repository, with the main code also part of OpenBSD. It runs on Linux, macOS and the BSDs; on Windows it runs inside WSL.
The design is a client and a server. The first tmux command starts a server in the background, which owns every session, window and pane and the programs running in them. Your terminal runs a client that draws one session and sends it your keys. Close the terminal or lose an SSH connection and only the client goes away; the server and everything inside it keep running until you attach again or run tmux kill-server.
Sessions, Windows and Panes
A session is a named workspace, usually one per project. A session holds windows, which behave like tabs and fill the terminal one at a time. A window is divided into panes, each running its own shell or program. Since tmux 3.7 a window can also have floating panes, which sit above the tiled layout and can be moved, resized and turned back into tiled panes.
Where tmux Fits
The two big reasons to learn tmux are remote work and keeping a project's terminals together. On a server, a build, a migration or a long test run inside tmux survives a dropped connection; you reconnect with ssh -t host 'tmux new -A -s main' and pick up where you left off. On your own machine, a workspace script can open your editor, dev server, tests and logs in one command. Editors with remote support, such as VS Code Remote SSH, cover part of the same ground, but they stop when the editor window closes, while tmux sessions do not.
tmux pairs naturally with a terminal editor and a good shell. For the editor side, the Vim cheat sheet covers the keys that copy mode borrows; for the shell, see the Bash cheat sheet and the Linux commands cheat sheet.
tmux, Screen and Terminal Tabs Compared
| tmux | GNU Screen | Terminal tabs and splits | |
|---|---|---|---|
| Survives closing the terminal | Yes | Yes | No |
| Survives a dropped SSH connection | Yes, when run on the server | Yes | No |
| Vertical and horizontal splits | Yes | Yes, since 4.1 | Depends on the terminal |
| Floating panes | Yes, since 3.7 | No | Some terminals |
| Scriptable from the shell | Every command, with formats | Limited | Depends on the terminal |
| Default prefix | C-b | C-a | None |
| Config file | ~/.tmux.conf | ~/.screenrc | Terminal settings |
Common tmux Mistakes
In the Config
- Editing tmux.conf and expecting a change. The server reads it once. Reload with
source-file, and for default-terminal start fresh withtmux kill-server. - Binding over a default you still need.
C-b rrefreshes the client,C-b lis last window,C-b gmoves floating panes in 3.8. Check withC-b /before you bind a key. - Copying an old config with removed options. Options like utf8, mouse-mode or status-utf8 were removed years ago and now print an error every time the file loads. Use
set -qfor options you know only some versions have. - Leaving escape-time at 500. Old configs and old tmux versions wait half a second after Escape, which makes Vim feel slow. tmux 3.5 and later default to 10 ms.
In Daily Use
- Starting tmux inside tmux by accident. Check for
$TMUXin your shell profile before auto-starting tmux. - Selecting text with the mouse and getting tmux's selection. Hold Shift, or Option in iTerm2, to use the terminal's own selection.
- Losing scrollback. The default history is 2000 lines per pane; raise history-limit before you need it.
- Killing the server to close one session. Use
tmux kill-session -t name;kill-servercloses everything.
How to Learn tmux Quickly
Week One: Five Keys
Start with tmux new -A -s main, then only C-b c, C-b %, C-b ", the arrows and C-b d. Detach and attach a few times until it is automatic; that alone gives you the main benefit, sessions that survive closing the terminal. Add C-b z to zoom and C-b [ to scroll when you miss them.
Week Two: Your Own Config
Generate a tmux.conf with the builder on this page, read each line, and keep only what you understand. Then turn your most common project setup into a workspace script and put it with your other tooling, next to your Git and Docker commands. Teams that live in the terminal, especially in DevOps and on-call work, often share one tmux.conf and one startup script per service.
How This tmux Cheat Sheet Is Maintained
The default key bindings were extracted from key-bindings.c in the tmux 3.8 source, option names and defaults from options-table.c, and every command and flag in the code examples and tables was checked against the tmux 3.8 manual page by a script. Release dates and version notes come from the CHANGES file in the tmux repository. The page is reviewed when a new tmux release comes out.
Sources: the tmux 3.8 manual page (tmux.1), key-bindings.c, options-table.c and CHANGES in the tmux source repository; the tmux wiki; the TPM, tmux-resurrect and tmux-continuum README files.
tmux Questions People Actually Ask
What is tmux used for?
tmux keeps terminal sessions running on a machine after you disconnect, and splits one terminal into many windows and panes. Developers use it to keep an editor, a server, tests and logs side by side, and to reconnect to long jobs on remote servers after an SSH connection drops.
What is the tmux prefix key?
The prefix is the key you press before a tmux shortcut, C-b by default: hold Ctrl, press b, release, then press the command key. C-b c opens a window and C-b d detaches. You can change it with set -g prefix C-a, and C-b C-b sends a literal C-b to the program in the pane.
How do I split a pane in tmux?
Press C-b % to split the current pane left and right, and C-b " to split it top and bottom. The commands are split-window -h and split-window -v; add -c "#{pane_current_path}" to open the new pane in the same directory, and -l 30% to set its size.
How do I scroll up in tmux?
Press C-b [ to enter copy mode, or C-b PgUp to enter it and scroll a page at once, then use the arrow keys, Page Up and Page Down, or the mouse wheel. Press q to leave. With the mouse option on, which is the default from tmux 3.8, the wheel enters copy mode by itself.
How do I copy text from tmux to the clipboard?
Turn on set -s set-clipboard on so tmux passes copies to your terminal with the OSC 52 escape sequence, which also works over SSH. Then select in copy mode and press Enter in vi mode or M-w in emacs mode. On a terminal without OSC 52, set copy-command to pbcopy, wl-copy or xclip.
How do I reload tmux.conf without restarting?
Run tmux source-file ~/.tmux.conf from a shell, or C-b : then source-file ~/.tmux.conf. Many configs bind it to a key, for example bind R source-file ~/.tmux.conf. A few settings, such as default-terminal, only apply to new sessions or after tmux kill-server.
What is the difference between tmux sessions, windows and panes?
A session is a named workspace that keeps running on the tmux server. Each session holds windows, which work like tabs and fill the whole terminal. Each window is split into one or more panes, and every pane runs its own shell or program.
What is new in tmux 3.8?
tmux 3.8, released on September 9, 2026, adds modal floating panes, built-in light and dark themes, a fuzzy switcher on C-b Tab and C-b S-Tab, monitor hooks and OSC 133 command events, and turns the mouse on by default. Floating panes themselves arrived in tmux 3.7.
Is tmux better than GNU Screen?
For most people, yes. tmux has a clearer command language, scriptable formats, vertical and horizontal splits, floating panes, hooks and active development, while GNU Screen still wins on serial console support and is installed on some older systems by default. The keys are different, but setting the tmux prefix to C-a feels familiar.
Can I download this tmux cheat sheet as a PDF?
Yes. Use your browser's print command and choose Save as PDF. The print layout keeps every table, snippet and explanation and leaves out the search box, navigation and tools. Run a search first to print only the rows that are still visible.