Reference

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 sessionIn the shell, run tmux
  • Start a named sessionIn the shell, run tmux new -s name
  • Attach to a session, creating it if missingIn the shell, run tmux new -A -s name
  • List sessionsIn the shell, run tmux ls
  • Attach to the most recent session — unattached ones firstIn the shell, run tmux a
  • Attach to a named sessionIn the shell, run tmux a -t name
  • Attach and detach every other clientIn the shell, run tmux a -d -t name
  • Detach from the sessionCtrlbdorAt the tmux prompt, type detach
  • Choose a client to detachCtrlbD
  • Rename the current sessionCtrlb$orAt the tmux prompt, type rename-session name
  • Browse and switch sessionsCtrlbs
  • Previous / next sessionCtrlb( or )
  • Back to the last sessionCtrlbL
  • Kill a sessionIn the shell, run tmux kill-session -t name
  • Kill every session except the current oneAt the tmux prompt, type kill-session -a
  • Kill the server and all its sessionsIn 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 windowCtrlbcorAt the tmux prompt, type new-window -n name
  • Rename the current windowCtrlb,orAt 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&orAt the tmux prompt, type kill-window
  • Move the window to another indexCtrlb.orAt the tmux prompt, type move-window -t index
  • Move the window one place left, keeping it selectedAt the tmux prompt, type swap-window -d -t -1
  • Move the window one place right, keeping it selectedAt the tmux prompt, type swap-window -d -t +1
  • Swap two windowsAt the tmux prompt, type swap-window -s src -t dst
  • Close the gaps in window numbersAt the tmux prompt, type move-window -r
  • Move the window to another sessionAt 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%orAt the tmux prompt, type split-window -h
  • Split into top and bottomCtrlb"orAt the tmux prompt, type split-window -v
  • Split, staying in the current directoryAt 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, -RAt 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!orAt the tmux prompt, type break-pane
  • Mark / unmark the current paneCtrlbm or M
  • Bring the marked pane into this windowAt the tmux prompt, type join-pane
  • Bring a pane from another window — -h for side by sideAt the tmux prompt, type join-pane -s window.pane
  • Send the current pane to another window — a marked pane goes insteadAt 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 firstCtrlbxorAt the tmux prompt, type kill-pane
  • Close every other paneAt 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 modeAt the tmux prompt, type setw -g mode-keys vi
Inside copy modeviemacs
Leave copy modeqqorEsc
Move the cursorhjklarrow keys
Page up / downCtrlb or CtrlfAltv or Ctrlv
Half a page up / downCtrlu or CtrldAltUp or AltDown
Top / bottom of the historyg or GAlt< or Alt>
Previous / next word — emacs M-f: word endb or wAltb or Altf
Start / end of the line0 or $Ctrla or Ctrle
Go to a line number:g
Search down / up/ or ?Ctrls or Ctrlr
Next / previous matchn or Nn or N
Start a selectionSpaceCtrlSpace
Select the whole lineVNo default key
Toggle a rectangle selectionvR
Clear the selectionEscCtrlg
Copy the selection and leaveEnterAltw
Copy to the end of the line and leaveDCtrlk

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#orAt the tmux prompt, type list-buffers
  • Delete the newest bufferCtrlb-
  • Print the newest bufferIn the shell, run tmux show-buffer
  • Save the newest buffer to a fileAt the tmux prompt, type save-buffer file
  • Load a file into a new bufferAt the tmux prompt, type load-buffer file
  • Save a pane's whole historyIn 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 configurationAt the tmux prompt, type source-file ~/.tmux.conf
  • Turn on the mouse — click, drag to resize, wheel to scrollAt the tmux prompt, type set -g mouse on
  • Number windows from 1At the tmux prompt, type set -g base-index 1
  • Number panes from 1At the tmux prompt, type setw -g pane-base-index 1
  • Renumber windows when one closesAt the tmux prompt, type set -g renumber-windows on
  • Keep more scrollback — applies to new panesAt the tmux prompt, type set -g history-limit 50000
  • Change the prefix to C-aAt the tmux prompt, type set -g prefix C-a
  • …and let C-a C-a send a literal C-aAt the tmux prompt, type bind C-a send-prefix
  • Send the prefix key to the programCtrlbCtrlb
  • Open a floating shellAt 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 commandIn the shell, run tmux list-keys
  • Describe what one key doesCtrlb/
  • List commands with their flagsIn the shell, run tmux list-commands
  • Read the manualIn the shell, run man tmux
  • Show global session optionsAt the tmux prompt, type show -g
  • Show global window optionsAt the tmux prompt, type show -gw
  • Show the value of one optionAt the tmux prompt, type show -gv option
  • Show previous tmux messagesCtrlb~
  • Show information about the windowCtrlbi
  • List every window on the serverIn the shell, run tmux lsw -a
  • List every pane on the serverIn the shell, run tmux lsp -a
  • Print the current session:window.paneIn the shell, run tmux display -p '#S:#I.#P'
  • Show the tmux versionIn the shell, run tmux -V