Contents

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.

~/.tmux.conf

    

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.

dev.sh

    

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 Homebrew

Check 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 -V

Build 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 install

Command line flags

FlagDoes
tmux -VPrint the version
tmux -f fileUse another config file
tmux -L nameUse a separate server with its own socket name
tmux -S /path/to/socketUse a server socket at that path
tmux -2Assume the terminal supports 256 colours
tmux -vWrite 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 again

Attach 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 work

The keys you need on day one

KeysWhat they do
C-b cNew window
C-b %Split the pane left and right
C-b "Split the pane top and bottom
C-b arrowMove to the pane in that direction
C-b zZoom the pane to the full window and back
C-b dDetach 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.

NotationMeaning
C-bCtrl and b, the default prefix
M-xMeta, usually Alt, and x
S-LeftShift and the left arrow
C-b C-bSend a literal C-b to the program in the pane
PPage, NPagePage Up and Page Down
BTabShift and Tab
DCDelete

Find out what a key does

Keys or commandResult
C-b ?Browse all bindings with their notes
C-b / then a keyDescribe that one key
tmux list-keys -NPrint bindings that have notes
tmux list-keys -T copy-mode-viPrint 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.

~/.tmux.conf
unbind C-b
set -g prefix C-a
bind C-a send-prefix

Keep 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-Space

Sessions

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 command

Attach, 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 session

Check 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 running

Session 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.

KeysAction
C-b dDetach the current client
C-b DChoose a client to detach
C-b sPick a session from a tree
C-b $Rename the session
C-b ( and C-b )Previous and next session
C-b LLast session you used
C-b S-TabFuzzy 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 work

Windows

Window keys

Create, move between and close windows

KeysAction
C-b cNew window
C-b n and C-b pNext and previous window
C-b lLast window you were in
C-b 0 to C-b 9Window 0 to 9
C-b 'Prompt for a window index
C-b wPick a window from a tree
C-b TabFuzzy window switcher (3.8)
C-b ,Rename the window
C-b .Move the window to another index
C-b fFind a window by its text
C-b &Kill the window, after a y/n prompt
C-b M-n and C-b M-pNext 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 -r

Stop 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 off

Number 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.

~/.tmux.conf
set -g base-index 1
setw -g pane-base-index 1
set -g renumber-windows on

Panes & Splits

Pane keys

Split, move and close

KeysAction
C-b %Split left and right
C-b "Split top and bottom
C-b arrowGo to the pane in that direction
C-b oNext pane
C-b ;Last active pane
C-b qShow pane numbers, type one to jump
C-b zZoom or unzoom the pane
C-b xKill 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-oRotate panes forward and backward
C-b TSet 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.

KeysAction
C-b C- arrowResize by 1 cell, repeatable
C-b M- arrowResize by 5 cells, repeatable
C-b ESpread 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 -Z

Move 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 2

Mark a pane, then use it as a target

Keys or commandAction
C-b mMark or unmark the active pane
C-b MClear the mark
join-paneWith no -s, joins the marked pane here
swap-paneWith 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 -a

Restart 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 on

Name 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

tmux 3.8

Create and switch between floating and tiled

KeysAction
C-b *New floating pane
C-b @Float a tiled pane, or tile a floating one
C-b g then a keyMove the floating pane
C-b M- arrowResize it, as for tiled panes
Ctrl and dragDraw a new floating pane with the mouse

Move keys after C-b g

KeyMoves the floating pane to
1 2 3 4Top left, top right, bottom left, bottom right corner
M-1 to M-4That corner, resized to a quarter of the window
ArrowThe middle of that edge
M- arrowThat half of the window
0Fill the whole window
,A menu of positions

new-pane

tmux 3.7 and later

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

tmux 3.8

-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

tmux 3.8

-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

KeysLayout
C-b SpaceNext layout
C-b M-1even-horizontal: side by side
C-b M-2even-vertical: stacked
C-b M-3main-horizontal: big pane on top
C-b M-4main-vertical: big pane on the left
C-b M-5tiled: a grid
C-b M-6main-horizontal-mirrored: big pane at the bottom
C-b M-7main-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 -E

Save 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

KeysAction
C-b [Enter copy mode
C-b PgUpEnter copy mode and scroll up a page
Mouse wheelEnter copy mode and scroll, with the mouse option on
qLeave 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.

~/.tmux.conf
set -g history-limit 50000

Emacs 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.

KeysAction
C-SpaceStart a selection
M-w or C-wCopy the selection and leave copy mode
C-gClear the selection
RToggle rectangle selection
C-s and C-rSearch down and up
n and NNext and previous match
M-< and M->Top and bottom of the history
C-v and M-vPage down and up
gGo to a line
LToggle line numbers
C-M-Up and C-M-DownPrevious 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.

~/.tmux.conf
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-toggle

Default vi copy mode keys

Movement

KeysAction
h j k lLeft, down, up, right
w b eNext word, previous word, end of word
0 ^ $Start of line, first non-blank, end of line
g and GTop and bottom of the history
H M LTop, middle and bottom of the screen
C-u and C-dHalf a page up and down
C-b and C-fA page up and down
{ and }Previous and next paragraph
%Matching bracket
f F t TJump to a character, like Vim
:Go to a line

Search, select and copy

KeysAction
/ and ?Search down and up
n and NNext and previous match
* and #Search for the word under the cursor
SpaceStart a selection
VSelect the whole line
vToggle rectangle selection
oJump to the other end of the selection
EnterCopy the selection and leave
AAppend the selection to the last buffer and leave
DCopy to the end of the line and leave
EscapeClear the selection
qLeave 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.

~/.tmux.conf
set -s set-clipboard on

Pipe 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.

KeysAction
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 buffer

Paste into another pane from a script

$ tmux paste-buffer -t api:1.2

Mouse

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 off

Select 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.

TerminalHold while dragging
Most Linux terminalsShift
iTerm2Option
Windows TerminalShift

Select the pane under the mouse without clicking

tmux 3.7

set -g focus-follows-mouse on

Drag-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-clear

tmux.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.

PathUsed for
~/.tmux.confYour config
$XDG_CONFIG_HOME/tmux/tmux.confYour config, XDG style
~/.config/tmux/tmux.confYour config, XDG style
/etc/tmux.confSystem-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 new

A 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.

~/.tmux.conf
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 on

Split 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 5

Key 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-z

Key tables you can bind in

TableActive when
prefixAfter the prefix key
rootAlways, no prefix
copy-modeCopy mode with Emacs keys
copy-mode-viCopy mode with vi keys
moveAfter C-b g, for floating panes (3.8)
Any nameAfter 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.

CommandScope
set -s escape-time 10Server: one value for everything
set -g status-style bg=blackSession: the global default for all sessions
set status-style bg=redSession: only the current session
setw -g mode-keys viWindow: the global default for all windows
set -p window-style bg=colour235Pane: 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-limit

Your 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.

~/.tmux.conf
set -g status-position top
set -g status-interval 5
set -g status-style "bg=default,fg=colour250"
set -g status-justify centre

Left 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 off

Default contents

OptionDefault
status-left[#{session_name}]
status-left-length10
status-right-length40
window-status-format#I:#W#{?window_flags,#{window_flags}, }
status-interval15

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

AliasVariableValue
#Ssession_nameSession name
#Iwindow_indexWindow index
#Wwindow_nameWindow name
#Fwindow_flagsWindow flags such as * for current and Z for zoomed
#Ppane_indexPane index
#Dpane_idUnique pane ID such as %3
#Tpane_titlePane title
#HhostHostname
#hhost_shortHostname 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

FormatResult
#{?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

FormatResult
#{=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

StyleMeaning
fg=red,bg=blackForeground and background colour
fg=colour208One of the 256 colours
fg=#ff870024-bit hex colour
bg=defaultThe terminal's own background
bold, italics, reverse, dimAttributes; 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

tmux 3.8

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 terminal

Use 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.

dev.sh
#!/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

TargetMeans
apiSession api
api:2Window 2 in session api
api:logsThe window named logs
api:2.1Pane 1 in window 2
%7Pane 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 output

Wait 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

tmux 3.8

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

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.

CommandDoes
set-hook -B name:what:formatMonitor hook: checks a format every second and runs when the value changes
set-hook -TWith -B, run only while the format is true
set-hook -E @eventFire a user event right away
wait-for -EBlock until a hook, notification or user event fires
show-hooks -BList 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; done

Plugins (TPM)

tmux Plugin Manager

Install TPM

$ git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm

List 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.

~/.tmux.conf
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.

KeysAction
C-b IInstall the plugins listed in tmux.conf
C-b UUpdate plugins
C-b M-uRemove plugins no longer listed
C-b C-sSave sessions, with tmux-resurrect
C-b C-rRestore 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.

KeysGoes to
C-b cThe outer tmux
C-b C-b cThe 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 user

Grouped 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-view

Read-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 mail

Troubleshooting

Common problems

Error messages and what they mean

MessageFix
sessions should be nested with care, unset $TMUX to forceYou 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/defaultNo session exists yet; start one with tmux new
can't find session: apiCheck 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 commandShows
C-b ~Recent messages, including config errors
tmux show -gEvery global session option
tmux show -sEvery server option
tmux -vv newWrites debug logs to tmux-server-PID.log in the current directory
tmux source-file -v ~/.tmux.confEach 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.conf

tmux 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.

VersionReleasedHighlights
3.8September 9, 2026Modal 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.7June 26, 2026Floating panes, new-pane, line numbers in copy mode, focus-follows-mouse, history-limit changes apply to existing panes
3.6November 26, 2025Better second and third status lines, light and dark theme reporting to applications, case-insensitive search in modes
3.5September 27, 2024escape-time default down to 10 ms, mirrored main layouts, prefix-timeout option
3.4February 13, 2024The version in Ubuntu 24.04

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


tmux Shortcuts Quick Reference

The thirty bindings most people use every day. Each one starts with the prefix, C-b, unless you changed it.

TaskKeys
Detach from the sessionC-b d
Pick a sessionC-b s
Rename the sessionC-b $
New windowC-b c
Next and previous windowC-b n, C-b p
Go to window 3C-b 3
Last windowC-b l
Rename the windowC-b ,
Pick a windowC-b w
Kill the windowC-b &
Split left and rightC-b %
Split top and bottomC-b "
Move between panesC-b and an arrow
Show pane numbersC-b q
Zoom a paneC-b z
Kill the paneC-b x
Pane to its own windowC-b !
Resize a paneC-b C- or C-b M- and an arrow
Next layoutC-b Space
New floating pane (3.8)C-b *
Float or tile a pane (3.8)C-b @
Enter copy modeC-b [
PasteC-b ]
Choose a paste bufferC-b =
Command promptC-b :
List all bindingsC-b ?
Describe one keyC-b /
Show recent messagesC-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

tmuxGNU ScreenTerminal tabs and splits
Survives closing the terminalYesYesNo
Survives a dropped SSH connectionYes, when run on the serverYesNo
Vertical and horizontal splitsYesYes, since 4.1Depends on the terminal
Floating panesYes, since 3.7NoSome terminals
Scriptable from the shellEvery command, with formatsLimitedDepends on the terminal
Default prefixC-bC-aNone
Config file~/.tmux.conf~/.screenrcTerminal 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 with tmux kill-server.
  • Binding over a default you still need. C-b r refreshes the client, C-b l is last window, C-b g moves floating panes in 3.8. Check with C-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 -q for 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 $TMUX in 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-server closes 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.