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) #
Windows (like tabs) #
Moving & swapping windows #
# run these from the command prompt: Ctrl-b :
:swap-window -t 2 # swap this window with window 2
:move-window -t 9 # renumber this window to 9
:swap-window -s 3 -t 1 # swap windows 3 and 1
Panes (splits) #
Resizing panes #
:resize-pane -L 10 # grow 10 cells left (-R, -U, -D likewise)
Synchronized panes #
:setw synchronize-panes on # keystrokes go to every pane in the window
:setw synchronize-panes off # back to typing in one pane
Copy mode #
:capture-pane -S -3000 # copy the last 3000 lines into a buffer
:save-buffer ~/pane.txt # write the buffer to a file
tmux capture-pane -pS -3000 > pane.txt # one shot from the shell
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