Skip to main content
tmux

Key Bindings

Step 5 of 8

Key Bindings

tmux key bindings follow a simple pattern: prefix + command.

The prefix key (default Ctrl-b) tells tmux "the next key is for tmux, not the shell". After pressing prefix, you have about 1 second to press the command key.

NOTE:

Think of prefix like Alt or Ctrl in other apps — it modifies the meaning of the next keypress.

The prefix key

Default: Ctrl-b

  1. Press and hold Ctrl
  2. Press b
  3. Release both
  4. Press the command key

Example: Ctrl-b d (detach)

NOTE:

Ctrl-b is awkward for many — it requires reaching. We'll remap it in Step 7.

Why Ctrl-b?

GNU screen (tmux's predecessor) uses Ctrl-a. tmux chose Ctrl-b because:

  • Ctrl-a is commonly used for "beginning of line" in shell readline
  • Ctrl-b is "backward one character" (less common)

Many users remap to Ctrl-a anyway (or Ctrl-space, Ctrl-q).

Listing all key bindings

Show every key binding:

$

This opens a scrollable list. Use arrow keys or page up/down to browse.

NOTE:

Press q or Esc to exit the help list.

From command line

List all bindings:

$

List bindings containing a specific key:

$

Command mode

Enter command mode:

$

You can type any tmux command by name. Tab-completion works!

Examples:

  • new-session -s mysession
  • split-window -v
  • rename-window tests
NOTE:

Command mode is powerful. If there's no key binding for something, there's probably a command for it.

Common prefix commands

KeyAction
dDetach from session
?List key bindings
:Command prompt
[Enter copy mode (scroll)
]Paste from buffer
=Choose buffer to paste
~Show paste buffers

Session commands

KeyAction
sList sessions
$Rename session
(Switch to previous session
)Switch to next session
LSwitch to last session

Window commands

KeyAction
cCreate new window
wChoose window
nNext window
pPrevious window
0-9Jump to window number
,Rename window
&Kill window
fFind window
FFind window by name

Pane commands

KeyAction
%Split vertical (left/right)
"Split horizontal (top/bottom)
oCycle panes
qShow pane numbers
xKill pane
zZoom pane
!Break pane to window
{Swap pane with previous
}Swap pane with next
;Last active pane
oRotate panes forward

Copy mode commands

Enter copy mode with Ctrl-b [, then:

KeyAction
↑↓Scroll line by line
Ctrl-b / Ctrl-fScroll page up/down
gGo to top
GGo to bottom
/Search forward
?Search backward
SpaceStart selection
EnterCopy selection
q / EscExit copy mode
NOTE:

Copy mode uses vi keys by default. Emacs mode is available (we'll cover in Step 7).

Nested tmux

When you attach to a tmux inside tmux (common with SSH), you need to send prefix to the inner session:

$

This sends Ctrl-b to the inner tmux.

NOTE:

Nested tmux can be confusing. Consider using Ctrl-a for local, Ctrl-b for remote.

Key binding modes

tmux has two modes for key bindings:

  • emacs (default): emacs-style movement
  • vi: vi-style movement

Check current mode:

$

Listing options

Show all options:

$

Show specific option:

$

Key binding table

Key bindings are organized into key tables:

  • root: Default prefix bindings
  • copy-mode: Bindings in copy mode
  • choice-mode: Interactive selection bindings
  • edit-mode: Command line editing

View bindings in a specific table:

$

Custom key bindings

Create temporary binding:

$

Type: bind-key X kill-session

Now Ctrl-b X kills the current session.

NOTE:

Temporary bindings are lost when tmux exits. For permanent bindings, use .tmux.conf (Step 7).

Unbinding keys

Remove a key binding:

$

Type: unbind-key %

Now Ctrl-b % (split vertical) does nothing.

Viewing bound command

Find what a key does:

$

Output: bind-key -T root % split-window -h

Next steps

Now that you understand key bindings, you can customize them. In Step 7, we'll create a .tmux.conf file to:

  • Remap prefix to Ctrl-a
  • Add sensible key bindings
  • Enable vi mode
  • Customize the status bar
NOTE:

Memorize 5-10 key bindings you use daily. Look up the rest as needed.


Next: Step 6 → Copy Mode — Scroll, search, and copy without a mouse