tmux Cheatsheet

tmux is an essential utility for anybody who does a lot of work in terminal windows on Unix systems. It allows you to create multiple virtual terminals, switch between them, detach from them and reattach later and/or from elsewhere, and persists even if your connection to the host system fails or you need to drop it for some reason.

The following is a basic overview and reference for common use of tmux.

Typography:

  • Monospace indicates a command you type: tmux new
  • C-b c is a keystroke combination where you hold down the control key and press the B key, then press C

Starting tmux

tmux new [-s title]
create a new tmux session, optionally with the given title
tmux attach [-t title]
attach to an existing session, optionally that specified

In-session tmux commands

Essential

C-b C-a
switch to previous screen
C-b c
create a new virtual screen
C-b n
switch to the next screen
C-b p
switch to the previous screen
C-b <#>
switch to the given screen
C-b d
detach current session

Once you’ve got the essentials

C-b ,
set a title for the current pane

More advanced: locking/unlocking panes

These are useful for long-running proceses you don’t want to accidentally kill.

Instead of keystrokes, these are commands you enter at the tmux prompt, invoked with C-b :.

select-pane -d
lock the current pane to input
select-pane -e
unlock the current pane to input

More advanced: scrollback buffer

This one takes a bit more explanation as it is a “mode”, so this is a sequence to enter the mode, examine the buffer, and leave the scrollback mode.

C-b [
enter scrollback mode. In the top right corner an indicator for the current position within and length of the buffer is displayed.
Up, down, page up, page down
navigate the scrollback buffer.
C-c
Exit scrollback mode