Tmux
From Leo's Notes
This page was last edited on 11 March 2020, at 22:49.
tmux is a terminal multiplexer similar to Screen.
Quick Usage
| Command | Description |
|---|---|
| tmux ls | Lists all tmux sessions |
| tmux new -s session-name | Creates a new session named session-name |
| attach | Attaches to an existing session |
| tmux kill-session -t session-name | Kills a session by name |
| tmux kill N | Kills a session by ID |
Commands
All commands to tmux is prefixed with a key (Ctrl-b as opposed to Ctrl-a in screen).
General commands:
| Command | Description |
|---|---|
| d | Detach from this session |
| t | Shows a clock in the current pane |
| ? | Shows key bindings |
| : | Enters the tmux command prompt, where you can enter commands |
Windows (tab) commands:
| Command | Description |
|---|---|
| c | Creates a new window |
| w | Lists windows |
| n | Go to next window |
| p | Go to previous window |
| & | Kills the current window |
| , | Name the current window |
Panes (split) commands. Enable mouse (see below) to make switching and resizing panes easy.
| Command | Description |
|---|---|
| % | Vertical split (up over down symbol) |
| " | Horizontal split (2 quotes side by side) |
| x | Kill pane |
| o | Swap panes |
| q | Show pane numbers |
Similar to screen, enter copy mode with Ctrl-b [. You can use Vim key bindings if you set the mode-keys in the settings (see below). Exit copy mode by pressing Enter.
Configuration
Configuration can be set in ~/.tmux.conf file. Some useful settings are given below.
# Enable Vim key bindings in copy-mode
setw -g mode-keys vi
# Enable mouse, useful for selecting or resizing panes
set-option -g mouse on
# make scrolling with wheels work
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
bind -n WheelDownPane select-pane -t= \; send-keys -M