Skip to main content

Prefix Key and Keybindings

The prefix key is the gateway to every tmux command. Building muscle memory for the key bindings is the single most valuable tmux skill.

Core Idea

Every tmux shortcut = prefix + command key. The default prefix is Ctrl+b. You must press and release the prefix before the command key.

How the Prefix Works

Step 1: Press Ctrl+b   (press and release)
Step 2: Press d (detach)

This is NOT the same as Ctrl+b+d (all pressed simultaneously). Many beginners make this mistake.

warning

Hold Ctrl+b, release, then press the command key. Do not hold all keys simultaneously.

The Complete Key Binding Reference

Session Management

ShortcutAction
Ctrl+b dDetach from session
Ctrl+b sList / switch sessions (interactive)
Ctrl+b $Rename current session
Ctrl+b (Previous session
Ctrl+b )Next session

Window Management

ShortcutAction
Ctrl+b cCreate new window
Ctrl+b ,Rename current window
Ctrl+b nNext window
Ctrl+b pPrevious window
Ctrl+b lLast (previously active) window
Ctrl+b 0-9Jump to window by number
Ctrl+b wInteractive window list
Ctrl+b &Kill current window (with confirm)
Ctrl+b .Move window to new index

Pane Management

ShortcutAction
Ctrl+b %Split pane vertically
Ctrl+b "Split pane horizontally
Ctrl+b arrowNavigate panes
Ctrl+b oCycle through panes
Ctrl+b ;Last active pane
Ctrl+b qShow pane numbers
Ctrl+b zZoom/unzoom current pane
Ctrl+b !Break pane into new window
Ctrl+b xKill current pane (with confirm)
Ctrl+b {Move pane left
Ctrl+b }Move pane right
Ctrl+b SpaceCycle through layouts
Ctrl+b Alt+arrowResize pane

Copy Mode and Scrollback

ShortcutAction
Ctrl+b [Enter copy/scroll mode
Ctrl+b ]Paste from tmux buffer
Ctrl+b =Choose paste buffer
Ctrl+b #List paste buffers
Ctrl+b PgUpEnter copy mode and scroll up

Miscellaneous

ShortcutAction
Ctrl+b :Open command prompt
Ctrl+b ?Show all key bindings
Ctrl+b tShow clock (press q to exit)
Ctrl+b ~Show messages
Ctrl+b rReload config (if bound in config)

Changing the Prefix Key

Many users change the prefix to Ctrl+a (like GNU Screen):

~/.tmux.conf
# Unbind default prefix
unbind C-b

# Set new prefix
set -g prefix C-a
bind C-a send-prefix
note

Ctrl+a is easier to type, but conflicts with shell line-start shortcut on many terminals. Consider Ctrl+Space or Ctrl+\ as alternatives.

Creating Custom Key Bindings

~/.tmux.conf
# reload config with prefix + r
bind r source-file ~/.tmux.conf \; display "Config reloaded!"

# easy pane splits with | and -
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"

# vim-style pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# resize panes with vim-style keys
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

The -r flag makes the key repeatable — you can press it multiple times without re-pressing the prefix.

Listing Current Key Bindings

# inside tmux
Ctrl+b ?

# from command line
tmux list-keys

Removing a Key Binding

~/.tmux.conf
unbind C-b          # remove Ctrl+b default prefix
unbind '"' # remove horizontal split default

Key Binding Recommendation for Beginners

Add these to your ~/.tmux.conf to make tmux far more pleasant:

~/.tmux.conf
# Easier prefix
unbind C-b
set -g prefix C-a
bind C-a send-prefix

# Intuitive splits (remembers current path)
bind | split-window -h -c "#{pane_current_path}"
bind - split-window -v -c "#{pane_current_path}"

# Vim-style navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

# Reload config
bind r source-file ~/.tmux.conf \; display "Reloaded!"

What's Next