tmux #
A terminal multiplexer: run many shells in one terminal, split into panes, and keep sessions alive after you disconnect. Almost everything starts with the prefix Ctrl-b, then a key. Below, Ctrl-b c means press Ctrl-b, release, then c.
Sessions (from the shell) #
tmux # start a new session
tmux new -s work # new named session
tmux ls # list sessions
tmux attach -t work # attach to a session ( a = attach )
tmux kill-session -t work # kill one session
tmux kill-server # kill everything
Sessions (inside tmux) #
| Key | Action |
Ctrl-b d | Detach (session keeps running) |
Ctrl-b s | List / switch sessions |
Ctrl-b $ | Rename the session |
Ctrl-b ( ) | Previous / next session |
Windows (like tabs) #
| Key | Action |
Ctrl-b c | Create a window |
Ctrl-b , | Rename the window |
Ctrl-b n p | Next / previous window |
Ctrl-b 0–9 | Jump to window by number |
Ctrl-b w | List windows |
Ctrl-b & | Kill the window |
Panes (splits) #
| Key | Action |
Ctrl-b % | Split vertical (left/right) |
Ctrl-b " | Split horizontal (top/bottom) |
Ctrl-b ←↑↓→ | Move between panes |
Ctrl-b o | Cycle to the next pane |
Ctrl-b z | Zoom the pane (toggle fullscreen) |
Ctrl-b { } | Swap pane left / right |
Ctrl-b x | Kill the pane |
Ctrl-b space | Cycle pane layouts |
Copy mode #
| Key | Action |
Ctrl-b [ | Enter copy mode (scroll back) |
Space | Start selection (then move) |
Enter | Copy the selection |
Ctrl-b ] | Paste |
q | Quit copy mode |
/ ? | Search forward / backward |
Configuration #
# ~/.tmux.conf
set -g mouse on # mouse to select panes, scroll, resize
set -g base-index 1 # number windows from 1
setw -g mode-keys vi # vi keys in copy mode
bind r source-file ~/.tmux.conf # Ctrl-b r reloads the config
# remap the prefix to Ctrl-a (screen style)
unbind C-b
set -g prefix C-a
bind C-a send-prefix
tmux source-file ~/.tmux.conf # reload without restarting