Customize tmux keybindings by editing your ~/.tmux.conf
file. Add bindings with bind-key
or bind
and remove them with unbind-key
or unbind
. The default prefix key is Ctrl+b, which you can change to something more comfortable like Ctrl+a. Reload your configuration with Ctrl+b : source-file ~/.tmux.conf
.
bind-key -n C-l send-keys C-l
Tmux keybindings control how you interact with sessions, windows, and panes. The default keybindings are functional but can be customized extensively to match your workflow and preferences.
# Add a new binding bind-key k kill-window # or the shorter form bind k kill-window # Remove a binding unbind-key n # or the shorter form unbind n
In these examples, k
and n
are the keys being bound or unbound, while kill-window
is the tmux command being assigned.
Many users change the default prefix key from Ctrl+b to something more accessible:
# Change prefix to Ctrl+a (screen-like) unbind C-b set -g prefix C-a bind C-a send-prefix # Or change to Alt+b unbind C-b set -g prefix M-b bind M-b send-prefix
The send-prefix
command allows you to send the prefix key to nested applications (like vim) by pressing it twice.
# Bind without prefix (-n) bind -n C-l clear-history # Repeatable bindings (-r) bind -r h select-pane -L bind -r j select-pane -D bind -r k select-pane -U bind -r l select-pane -R # Define a key table (-T) bind -T copy-mode-vi v send -X begin-selection
The -n
flag creates a binding that works without pressing the prefix key first. The -r
flag makes a key repeatable, allowing you to press it multiple times after a single prefix key press. The -T
flag defines the key table for the binding, useful for mode-specific keys.
# Split panes with | and - unbind % bind | split-window -h unbind '"' bind - split-window -v # Reload config with r bind r source-file ~/.tmux.conf \; display "Config reloaded!" # Mouse mode toggle bind m set -g mouse on \; display "Mouse: ON" bind M set -g mouse off \; display "Mouse: OFF" # Switch between sessions bind S choose-session
These examples show how to make tmux more intuitive with logical split commands, easy config reloading, mouse mode toggling, and faster session switching.
If you're a Vim user, you might prefer Vim-style navigation keys:
# Use Vim-style pane navigation bind h select-pane -L bind j select-pane -D bind k select-pane -U bind l select-pane -R # Use Vim-style pane resizing 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
Create a binding to show all current key bindings for quick reference:
# Add to ~/.tmux.conf bind ? list-keys # Or for more details bind / list-keys -a
Then press Ctrl+b ? to see all your bindings. This is especially helpful after adding custom configurations.