tmux.md

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) #

KeyAction
Ctrl-b dDetach (session keeps running)
Ctrl-b sList / switch sessions
Ctrl-b $Rename the session
Ctrl-b ( )Previous / next session

Windows (like tabs) #

KeyAction
Ctrl-b cCreate a window
Ctrl-b ,Rename the window
Ctrl-b n pNext / previous window
Ctrl-b 09Jump to window by number
Ctrl-b wList windows
Ctrl-b &Kill the window

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) #

KeyAction
Ctrl-b %Split vertical (left/right)
Ctrl-b "Split horizontal (top/bottom)
Ctrl-b ←↑↓→Move between panes
Ctrl-b oCycle to the next pane
Ctrl-b zZoom the pane (toggle fullscreen)
Ctrl-b { }Swap pane left / right
Ctrl-b xKill the pane
Ctrl-b spaceCycle pane layouts

Resizing panes #

KeyAction
Ctrl-b Ctrl-←↑↓→Resize the pane one step in that direction
: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 #

KeyAction
Ctrl-b [Enter copy mode (scroll back)
SpaceStart selection (then move)
EnterCopy the selection
Ctrl-b ]Paste
qQuit copy mode
/ ?Search forward / backward

Exporting scrollback #

: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

© 2026 Anguished LLC · anguishedturtle.com · About · Bit Night Runner · Support · Privacy