kontrolplane
not accepting clients |
english english nederlands nederlands
← back to blog

terminal multiplexing with tmux

tmux keeps sessions alive, splits panes, and lets you context-switch without losing state. a short guide to the commands and configuration that matter most.

share

ssh into a machine, start a long-running process, lose the connection, lose the process. tmux solves this by decoupling the terminal from the session. the process keeps running whether or not you’re attached.

beyond persistence, tmux gives you panes, windows, and sessions - all inside a single terminal. no need to open five tabs or tile terminal windows manually.

core concepts

a session is a collection of windows. a window is a full-screen layout. a pane is a split within a window. sessions persist on the server until explicitly killed, surviving disconnects and terminal closures.

tmux new -s work          # create a named session
tmux ls                   # list sessions
tmux attach -t work       # reattach
tmux kill-session -t work # killing a named session

detach from inside a session with ctrl-b d. the session stays alive.

splits and navigation

the default prefix is ctrl-b. after pressing it:

zooming a pane with z is useful when you need a full-screen view of one pane temporarily without closing the others.

configuration

the defaults are workable but not great. a few changes in ~/.tmux.conf that make a difference:

# start window numbering at 1
set -g base-index 1
setw -g pane-base-index 1

# split with intuitive keys
bind | split-window -h
bind - split-window -v

starting indices at 1 matches keyboard layout - reaching for 0 as the first window is harder then starting from 1.

the tmux configuration used by myself, along with the rest of my terminal setup, is available in my dotfiles/tmux/.tmux.conf.

sessions as workspaces

the real productivity gain comes from using sessions as project workspaces:

tmux new -s infastructure
tmux new -s monitoring

switch between them with ctrl-b s to get a session picker, or ctrl-b ( and ) to cycle. each session preserves its layout, working directories, and running processes.

when it matters

tmux is most valuable when you’re working on remote machines. an ssh disconnect a database migration no longer means an interrupted operation with unknown state. the session keeps running, and you reattach when the connection recovers. but it is also often used on the desktop as a means to easily switch between different running processes.

references

[1] tmux github repository. “terminal multiplexer.”
github.com/tmux/tmux

[2] tmux manual. “tmux(1).“
man.openbsd.org/tmux

[3] levi van noort. “dotfiles - tmux configuration.”
github.com/levivannoort/dotfiles/blob/main/tmux/.tmux.conf

[ ready when you are ]

no forms.
no calls.
just email.