tmux cheat sheet.
Sessions, windows, panes, copy mode and the commands behind them, with tmux's default key bindings. Checked against tmux 3.5a.
- Ctrlbd
- Press Ctrl+b, then the key.
At the tmux prompt, type rename-session name- Press Ctrl+b, then ":" and then type the command; replace the marked part with your own value.
In the shell, run tmux ls- Run in your shell.
Sessions
A session is a set of windows that keeps running after you detach.
- Start a new session
In the shell, run tmux - Start a named session
In the shell, run tmux new -s name - Attach to a session, creating it if missing
In the shell, run tmux new -A -s name - List sessions
In the shell, run tmux ls - Attach to the most recent session — unattached ones first
In the shell, run tmux a - Attach to a named session
In the shell, run tmux a -t name - Attach and detach every other client
In the shell, run tmux a -d -t name - Detach from the sessionCtrlbdor
At the tmux prompt, type detach - Choose a client to detachCtrlbD
- Rename the current sessionCtrlb$or
At the tmux prompt, type rename-session name - Browse and switch sessionsCtrlbs
- Previous / next sessionCtrlb( or )
- Back to the last sessionCtrlbL
- Kill a session
In the shell, run tmux kill-session -t name - Kill every session except the current one
At the tmux prompt, type kill-session -a - Kill the server and all its sessions
In the shell, run tmux kill-server - Check whether a session exists (exit status)
In the shell, run tmux has -t name
Windows
Windows are full-screen tabs, listed in the status line.
- Create a windowCtrlbcor
At the tmux prompt, type new-window -n name - Rename the current windowCtrlb,or
At the tmux prompt, type rename-window name - Next / previous windowCtrlbn or p
- Go to window 0 to 9Ctrlb0 to 9
- Go to a window by index (prompts)Ctrlb'
- Back to the last windowCtrlbl
- Browse all windowsCtrlbw
- Find a window by its textCtrlbf
- Next / previous window with an alertCtrlbAltn or Altp
- Close the current window — asks firstCtrlb&or
At the tmux prompt, type kill-window - Move the window to another indexCtrlb.or
At the tmux prompt, type move-window -t index - Move the window one place left, keeping it selected
At the tmux prompt, type swap-window -d -t -1 - Move the window one place right, keeping it selected
At the tmux prompt, type swap-window -d -t +1 - Swap two windows
At the tmux prompt, type swap-window -s src -t dst - Close the gaps in window numbers
At the tmux prompt, type move-window -r - Move the window to another session
At the tmux prompt, type move-window -t session: - Window menuCtrlb<
Panes
Panes split a window. Resize keys repeat: press the prefix once, then the key several times.
- Split into left and rightCtrlb%or
At the tmux prompt, type split-window -h - Split into top and bottomCtrlb"or
At the tmux prompt, type split-window -v - Split, staying in the current directory
At the tmux prompt, type split-window -h -c "#{pane_current_path}" - Move to the pane in that directionCtrlbarrow keys
- Next paneCtrlbo
- Back to the last paneCtrlb;
- Show pane numbers; press one to jumpCtrlbq
- Zoom the pane in and outCtrlbz
- Resize by one cellCtrlbCtrlarrow keys
- Resize by five cellsCtrlbAltarrow keys
- Resize by an exact amount — also -U, -L, -R
At the tmux prompt, type resize-pane -D cells - Cycle through the preset layoutsCtrlbSpace
- Apply a preset layout — M-6, M-7 in tmux 3.5+CtrlbAlt1 to Alt7
- Spread panes out evenlyCtrlbE
- Swap with the previous / next paneCtrlb{ or }
- Rotate panes forward / backwardCtrlbCtrlo or Alto
- Break the pane out into its own windowCtrlb!or
At the tmux prompt, type break-pane - Mark / unmark the current paneCtrlbm or M
- Bring the marked pane into this window
At the tmux prompt, type join-pane - Bring a pane from another window — -h for side by side
At the tmux prompt, type join-pane -s window.pane - Send the current pane to another window — a marked pane goes instead
At the tmux prompt, type join-pane -t :window - Type into every pane at once (toggle)
At the tmux prompt, type setw synchronize-panes - Close the current pane — asks firstCtrlbxor
At the tmux prompt, type kill-pane - Close every other pane
At the tmux prompt, type kill-pane -a - Pane menuCtrlb>
Copy mode
Scroll, search and copy the pane's history. Enter it with the prefix; inside it the keys in the table are pressed on their own. They follow the mode-keys option: emacs by default, vi when $VISUAL or $EDITOR contains "vi".
- Enter copy modeCtrlb[
- Enter copy mode, one page upCtrlbPage Up
- Use vi keys in copy mode
At the tmux prompt, type setw -g mode-keys vi
| Inside copy mode | vi | emacs |
|---|---|---|
| Leave copy mode | q | qorEsc |
| Move the cursor | hjkl | arrow keys |
| Page up / down | Ctrlb or Ctrlf | Altv or Ctrlv |
| Half a page up / down | Ctrlu or Ctrld | AltUp or AltDown |
| Top / bottom of the history | g or G | Alt< or Alt> |
| Previous / next word — emacs M-f: word end | b or w | Altb or Altf |
| Start / end of the line | 0 or $ | Ctrla or Ctrle |
| Go to a line number | : | g |
| Search down / up | / or ? | Ctrls or Ctrlr |
| Next / previous match | n or N | n or N |
| Start a selection | Space | CtrlSpace |
| Select the whole line | V | No default key |
| Toggle a rectangle selection | v | R |
| Clear the selection | Esc | Ctrlg |
| Copy the selection and leave | Enter | Altw |
| Copy to the end of the line and leave | D | Ctrlk |
Buffers and pasting
Every copy lands in a paste buffer; the newest is pasted first.
- Paste the newest bufferCtrlb]
- Choose a buffer to pasteCtrlb=
- List buffersCtrlb#or
At the tmux prompt, type list-buffers - Delete the newest bufferCtrlb-
- Print the newest buffer
In the shell, run tmux show-buffer - Save the newest buffer to a file
At the tmux prompt, type save-buffer file - Load a file into a new buffer
At the tmux prompt, type load-buffer file - Save a pane's whole history
In the shell, run tmux capture-pane -p -S - -t pane > file
Command prompt and options
Any prompt command also runs as tmux <command> in the shell, and as a line in ~/.tmux.conf without the colon.
- Open the command promptCtrlb:
- Reload the configuration
At the tmux prompt, type source-file ~/.tmux.conf - Turn on the mouse — click, drag to resize, wheel to scroll
At the tmux prompt, type set -g mouse on - Number windows from 1
At the tmux prompt, type set -g base-index 1 - Number panes from 1
At the tmux prompt, type setw -g pane-base-index 1 - Renumber windows when one closes
At the tmux prompt, type set -g renumber-windows on - Keep more scrollback — applies to new panes
At the tmux prompt, type set -g history-limit 50000 - Change the prefix to C-a
At the tmux prompt, type set -g prefix C-a - …and let C-a C-a send a literal C-a
At the tmux prompt, type bind C-a send-prefix - Send the prefix key to the programCtrlbCtrlb
- Open a floating shell
At the tmux prompt, type display-popup -E - Browse and edit options and bindingsCtrlbC
- Suspend the tmux clientCtrlbCtrlz
- Redraw the screenCtrlbr
- Show a big clockCtrlbt
Help and introspection
tmux documents itself: these answer most questions without leaving the terminal.
- Show the key bindings, describedCtrlb?
- List every key binding as a command
In the shell, run tmux list-keys - Describe what one key doesCtrlb/
- List commands with their flags
In the shell, run tmux list-commands - Read the manual
In the shell, run man tmux - Show global session options
At the tmux prompt, type show -g - Show global window options
At the tmux prompt, type show -gw - Show the value of one option
At the tmux prompt, type show -gv option - Show previous tmux messagesCtrlb~
- Show information about the windowCtrlbi
- List every window on the server
In the shell, run tmux lsw -a - List every pane on the server
In the shell, run tmux lsp -a - Print the current session:window.pane
In the shell, run tmux display -p '#S:#I.#P' - Show the tmux version
In the shell, run tmux -V