tmux
Invocation options
| control mode (can be used with iTerm2) | tmux -CC |
| create new session with a name | tmux new-session -s $SESSIONNAME -d |
| create new session, but leave unattached | tmux new-session -d |
| list sessions | tmux ls |
| kill a particular session | tmux kill-session -t $SESSIONNAME |
Keyboard Shortcuts
The “tmux” combo as listed here represents Ctrl+B by default.
Window management
| New window | tmux + c |
| Rename window | tmux + , |
| Close window | tmux + & |
| Previous window | tmux + p |
| Next window | tmux + n |
| Select window by number | tmux + [0-9] |
| Move window | tmux + . [0-9] |
| Rename window | tmux + , |
Pane management
| Vertical split | tmux + % |
| Horizontal split | tmux + “ |
| Move pane to left | tmux + { |
| Move pane to right | tmux + } |
| Switch between layouts | tmux + Space |
| Move to pane | tmux + [Arrow keys] |
| Convert pane to window | tmux + ! |
| Close pane | tmux + x |
Session management
| Show all sessions | tmux + s |
Copy mode
Within copy mode, controls behave like vi.
| Enter copy mode | tmux + [ |
| Quit copy mode | q |
| Start selection | Space |
| Copy selection | Enter |
| Paste buffer contents | tmux + ] |
| Clear selection | Esc |
| Save buffer to file | :save-buffer output.txt |
Internal commands
| Send commands to all panes | :setw synchronize-panes |
| Set option for all sessions | :set -g OPTION |
| Set option for all windows | :setw -g OPTION |
| Show list of keyboard shortcuts | tmux + ? |
Sample .tmux.conf
# Make it use C-a, similar to screen..
unbind C-b
unbind l
set -g prefix C-a
bind-key C-a last-window
# Reload key
bind r source-file ~/.tmux.conf
# Terminal Settings
set -g default-terminal "screen-256color"
set -g history-limit 10240
# Mouse support
set-option -g mouse on
set-encoding=utf8
# THEME
set -g status-bg brightblack
set -g status-fg brightwhite
set -g status-interval 60
set -g status-left-length 30
set -g status-left '#[fg=white](#S) #[fg=red]#H#[default]'
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=blue]%H:%M#[default]'