Skip to content
xt-tools

tmux cheatsheet

Searchable reference of tmux sessions, windows, panes, copy mode, key bindings and config snippets.

Default prefix: press Ctrl-b, release, then the key. Commands starting with : go at the Ctrl-b : prompt or after tmux in a shell.

129 of 129 entries

tmux keys and commands
SectionKeys or commandDescription
SessionstmuxStart a new session.
Sessionstmux new -s <name>Start a new session with a name.
Sessionstmux new -A -s <name>Attach to a session, creating it first if it does not exist.
Sessionstmux new -d -s <name> "<command>"Start a detached session running a command.
Sessionstmux lsList sessions.
Sessionstmux attachAttach to the most recently used session (short: tmux a).
Sessionstmux attach -t <name>Attach to a named session.
Sessionstmux attach -d -t <name>Attach and detach every other client, so the window fits your terminal.
Sessionstmux kill-session -t <name>End a session and everything in it.
Sessionstmux kill-serverEnd every session and stop the server.
Sessionstmux rename-session -t <old> <new>Rename a session.
SessionsCtrl-b dDetach from the session; it keeps running.
SessionsCtrl-b DChoose a client to detach.
SessionsCtrl-b sChoose a session from a tree (also shows windows).
SessionsCtrl-b $Rename the current session.
SessionsCtrl-b ( Ctrl-b )Switch to the previous or next session.
SessionsCtrl-b LSwitch back to the last session.
WindowsCtrl-b cCreate a new window.
WindowsCtrl-b ,Rename the current window.
WindowsCtrl-b &Kill the current window (asks for confirmation).
WindowsCtrl-b n Ctrl-b pNext or previous window.
WindowsCtrl-b 0 … 9Select window 0 to 9.
WindowsCtrl-b 'Prompt for a window index to select.
WindowsCtrl-b lToggle to the last active window.
WindowsCtrl-b wChoose a window from a tree with previews.
WindowsCtrl-b fFind a window by name or visible text.
WindowsCtrl-b .Move the window to another index.
WindowsCtrl-b iShow information about the current window.
Windows:new-window -n <name> "<command>"Open a named window running a command.
Windows:swap-window -t -1Swap the current window with the previous one, moving it one position left.
Windows:move-window -rRenumber windows to close gaps.
Windows:setw monitor-activity onHighlight the window in the status bar when it has new output.
PanesCtrl-b %Split the pane left and right (side by side).
PanesCtrl-b "Split the pane top and bottom (stacked).
PanesCtrl-b ← ↑ → ↓Move to the pane in that direction.
PanesCtrl-b oMove to the next pane.
PanesCtrl-b ;Toggle to the last active pane.
PanesCtrl-b qShow pane numbers; press a number to jump to that pane.
PanesCtrl-b zZoom the pane to the full window, or restore it.
PanesCtrl-b xKill the current pane (asks for confirmation).
PanesCtrl-b !Break the pane out into a new window.
PanesCtrl-b { Ctrl-b }Swap the pane with the previous or next one.
PanesCtrl-b Ctrl-oRotate the panes in the window.
PanesCtrl-b SpaceCycle through the preset layouts.
PanesCtrl-b Alt-1 … Alt-5Preset layouts: even-horizontal, even-vertical, main-horizontal, main-vertical, tiled.
PanesCtrl-b Ctrl-←↑→↓Resize the pane by one cell.
PanesCtrl-b Alt-←↑→↓Resize the pane by five cells.
PanesCtrl-b mMark the pane (Ctrl-b M clears the mark); join-pane and swap-pane use it.
Panes:resize-pane -D 10Resize by a number of cells: -U, -D, -L or -R.
Panes:join-pane -s <window>Move a pane from another window into this one.
Panes:select-layout tiledApply a layout by name.
Panes:setw synchronize-panes onType into every pane of the window at once (off to stop).
Panes:split-window -h -c "#{pane_current_path}"Split side by side, starting in the current pane’s directory.
Panes:respawn-pane -kRestart the command running in the pane.
Panes:pipe-pane -o "cat >> ~/tmux.log"Toggle logging the pane output to a file.
Copy & pasteCtrl-b [Enter copy mode to scroll back and select text.
Copy & pasteCtrl-b PgUpEnter copy mode and scroll one page up.
Copy & pasteCtrl-b ]Paste the most recent buffer.
Copy & pasteCtrl-b =Choose a buffer to paste from a list.
Copy & pasteCtrl-b #List paste buffers.
Copy & pasteCtrl-b -Delete the most recent buffer.
Copy & pastetmux show-bufferPrint the most recent buffer.
Copy & pastetmux save-buffer <file>Write the most recent buffer to a file.
Copy & pastetmux capture-pane -p -S - > <file>Save the full scrollback of the current pane to a file.
Copy & pasteMouse dragWith mouse on, select text to copy it; hold Shift (Option in some terminals) for the terminal’s own selection.
Copy mode (vi keys)qLeave copy mode.
Copy mode (vi keys)h j k lMove left, down, up, right.
Copy mode (vi keys)w b eNext word, previous word, end of word.
Copy mode (vi keys)0 ^ $Start of line, first non-blank, end of line.
Copy mode (vi keys)H M LTop, middle or bottom of the visible screen.
Copy mode (vi keys)Ctrl-u Ctrl-dHalf a page up or down.
Copy mode (vi keys)Ctrl-b Ctrl-fA full page up or down.
Copy mode (vi keys)g GTop or bottom of the scrollback history.
Copy mode (vi keys)f F t TJump to a character on the line; ; and , repeat.
Copy mode (vi keys)/ ?Search down or up.
Copy mode (vi keys)n NNext or previous match.
Copy mode (vi keys)SpaceStart a selection.
Copy mode (vi keys)VSelect whole lines.
Copy mode (vi keys)vToggle rectangle (block) selection.
Copy mode (vi keys)oMove to the other end of the selection.
Copy mode (vi keys)EnterCopy the selection to a buffer and leave copy mode.
Copy mode (vi keys)EscapeClear the selection.
Copy mode (emacs keys)q EscapeLeave copy mode.
Copy mode (emacs keys)Ctrl-f Ctrl-b Ctrl-n Ctrl-pMove right, left, down, up (arrow keys work too).
Copy mode (emacs keys)Alt-f Alt-bNext or previous word.
Copy mode (emacs keys)Ctrl-a Ctrl-eStart or end of the line.
Copy mode (emacs keys)Alt-v Ctrl-vA page up or down.
Copy mode (emacs keys)Alt-< Alt->Top or bottom of the scrollback history.
Copy mode (emacs keys)Ctrl-s Ctrl-rSearch down or up; n and N repeat.
Copy mode (emacs keys)Ctrl-SpaceStart a selection.
Copy mode (emacs keys)RToggle rectangle (block) selection.
Copy mode (emacs keys)Alt-wCopy the selection to a buffer and leave copy mode.
Copy mode (emacs keys)Ctrl-gClear the selection.
Command line & scriptingCtrl-b :Open the command prompt.
Command line & scriptingCtrl-b ?List every key binding.
Command line & scriptingCtrl-b ~Show previous tmux messages.
Command line & scriptingCtrl-b tShow a big clock in the pane.
Command line & scriptingCtrl-b rRedraw the client, e.g. after garbled output.
Command line & scriptingCtrl-b Ctrl-zSuspend the tmux client.
Command line & scriptingtmux source-file ~/.tmux.confReload the configuration in a running server.
Command line & scriptingtmux send-keys -t <target> "make test" EnterType a command into another pane.
Command line & scripting-t <session>:<window>.<pane>Target syntax for most commands, e.g. -t work:2.1.
Command line & scriptingtmux display -p "#{session_name}"Print a format variable, e.g. the session name.
Command line & scriptingtmux show-options -gShow global options (-w for window options).
Command line & scriptingtmux list-keys -T copy-mode-viList the bindings of one key table.
Command line & scriptingtmux has-session -t <name>Exit status 0 if the session exists; useful in scripts.
Command line & scriptingtmux -VPrint the tmux version.
Config~/.tmux.confConfig file; tmux 3.1+ also reads ~/.config/tmux/tmux.conf.
Configset -g prefix C-aUse Ctrl-a as the prefix (add unbind C-b and bind C-a send-prefix).
Configbind C-a send-prefixPress the prefix twice to send it to the program inside.
Configset -g mouse onClick to select panes and windows, drag borders, scroll with the wheel.
Configset -g base-index 1Number windows from 1 instead of 0.
Configsetw -g pane-base-index 1Number panes from 1.
Configset -g renumber-windows onRenumber windows when one is closed.
Configset -g history-limit 50000Keep more scrollback lines per pane.
Configset -sg escape-time 10Shorter Escape delay, so Vim inside tmux reacts quickly.
Configsetw -g mode-keys viUse vi keys in copy mode (the default is emacs unless $EDITOR mentions vi).
Configset -g default-terminal "tmux-256color"Advertise 256 colours to programs inside tmux.
Configset -as terminal-features ",xterm-256color:RGB"Enable true colour for an outer terminal (tmux 3.2+).
Configset -g set-clipboard onCopy to the system clipboard through the terminal (OSC 52).
Configset -g focus-events onPass focus events to programs such as Vim.
Configbind r source-file ~/.tmux.conf \; display "Reloaded"Ctrl-b r reloads the config and confirms.
Configbind | split-window -h -c "#{pane_current_path}"Ctrl-b | splits side by side in the same directory.
Configbind - split-window -v -c "#{pane_current_path}"Ctrl-b - splits stacked in the same directory.
Configbind -r h select-pane -LRepeatable binding: press h several times after one prefix.
Configbind -n M-Left select-pane -LBinding without the prefix: Alt-← moves to the left pane.
Configbind -T copy-mode-vi v send -X begin-selectionVim-like v to start a selection in copy mode.
Configbind -T copy-mode-vi y send -X copy-selection-and-cancelVim-like y to copy and leave copy mode.
Configset -g status-position topMove the status bar to the top.