Skip to content

Tmux

Tmux is a terminal multiplexer that allows you to switch between multiple terminal sessions and windows.

Basic Commands

CommandDescription
tmuxStart a new tmux session
tmux new -s nameStart a new session with name
tmux lsList all tmux sessions
tmux aAttach to the last session
tmux a -t nameAttach to a session with name
tmux kill-session -t nameKill session with name
exit or Ctrl+A dDetach from current session

Session Management

CommandDescription
Ctrl+A $Rename current session
Ctrl+A dDetach from session
Ctrl+A sList sessions
Ctrl+A (Move to previous session
Ctrl+A )Move to next session

Window Management

CommandDescription
Ctrl+A cCreate new window
Ctrl+A ,Rename current window
Ctrl+A &Kill current window
Ctrl+A nMove to next window
Ctrl+A pMove to previous window
Ctrl+A 0-9Switch to window 0-9
Ctrl+A wList windows
Ctrl+A fFind window
Ctrl+A .Move window to another session

Pane Management

CommandDescription
Ctrl+A "Split pane horizontally
Ctrl+A %Split pane vertically
Ctrl+A arrowNavigate between panes
Ctrl+A oCycle through panes
Ctrl+A qShow pane numbers
Ctrl+A q 0-9Switch to pane by number
Ctrl+A zToggle pane zoom
Ctrl+A !Convert pane into window
Ctrl+A xKill current pane
Ctrl+A }Swap with next pane
Ctrl+A {Swap with previous pane
Ctrl+A Ctrl+arrowResize pane
Ctrl+A Alt+arrowResize pane (5 cells at a time)
Ctrl+A spacebarToggle between pane layouts

Copy Mode

CommandDescription
Ctrl+A [Enter copy mode
Ctrl+A ]Paste buffer
qQuit copy mode
SpaceStart selection (in copy mode)
EnterCopy selection (in copy mode)
/Search forward (in copy mode)
?Search backward (in copy mode)
nNext search match
NPrevious search match

Miscellaneous

CommandDescription
Ctrl+A :Enter command mode
Ctrl+A tShow clock
Ctrl+A ?List all key bindings
Ctrl+A ~Show messages
Ctrl+A iShow session info
Ctrl+A rReload tmux configuration

Common Configuration (for your .tmux.conf)

Terminal window
# Remap prefix from Ctrl+B to Ctrl+A
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %
# Reload config file
bind r source-file ~/.tmux.conf \; display "Config reloaded!"
# Enable mouse mode
set -g mouse on
# Don't rename windows automatically
set-option -g allow-rename off
# vim-like pane navigation
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Set 256 colour terminal
set -g default-terminal "screen-256color"
# Start window numbering at 1
set -g base-index 1
setw -g pane-base-index 1
# Increase scrollback buffer size
set -g history-limit 10000
# Enable vi mode
setw -g mode-keys vi

Useful Plugins (with TPM - Tmux Plugin Manager)

Terminal window
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect' # Save/restore sessions
set -g @plugin 'tmux-plugins/tmux-continuum' # Auto save sessions
set -g @plugin 'tmux-plugins/tmux-yank' # Better copy/paste
set -g @plugin 'dracula/tmux' # Dracula theme
# Initialize TMUX plugin manager
run '~/.tmux/plugins/tpm/tpm'

Plugin Shortcuts

CommandDescription
Ctrl+A IInstall plugins
Ctrl+A UUpdate plugins
Ctrl+A Alt+uUninstall unused plugins
Ctrl+A Ctrl+sSave session (with tmux-resurrect)
Ctrl+A Ctrl+rRestore session (with tmux-resurrect)