The moment tmux earned its place was a dropped VPN halfway through a long-running migration, on a host I could not easily get back into, with a process that did not take kindly to its parent shell vanishing. After that I stopped treating terminal multiplexers as a thing other people used and started treating them as the default way I open a shell on anything that matters.
The pitch is simple. tmux runs a session on the remote host that survives your connection dying. You attach to it, you do work, your laptop lid closes or your wifi sulks, and the session keeps running. You reattach later and everything is exactly where you left it, output and all. If you have ever lost a half-finished rsync to a network blip, you already understand why this matters.
The bare minimum that makes it usable
Default tmux is fine but the keybindings fight my fingers, so I have a small .tmux.conf that I copy to every machine. It is not clever and it does not need to be.
# screen-style prefix, old habits
set -g prefix C-a
unbind C-b
bind C-a send-prefix
# splits that match how I read a screen
bind | split-window -h
bind - split-window -v
# renumber windows when one closes
set -g renumber-windows on
# a status bar I can actually read
set -g status-bg colour235
set -g status-fg colour250
# more scrollback than the stingy default
set -g history-limit 50000
The prefix change is pure muscle memory from years of GNU screen. The split bindings are the only ones I genuinely could not live with the defaults for, because " and % for vertical and horizontal splits never once felt natural. Everything else is taste.
The workflow, not just the config
The config is the boring part. The workflow is where it pays off.
First thing I do on any server I will spend more than a minute on is tmux new -s work. Named sessions matter once you have more than one. When I come back, tmux ls shows what is running and tmux attach -t work drops me back in. If I forgot the name, tmux attach grabs the most recent one. That is ninety per cent of the daily use right there.
The other habit is one window per concern. A window tailing logs, a window with the editor, a window for poking at things. Switching between them is the prefix and a number, which is faster than alt-tabbing through terminal tabs and crucially survives the connection. Within a window I split panes when I want to watch two things at once, typically a process running on the left and htop or a log on the right.
A few things I learned the slightly harder way:
- Detach with prefix then
d, do not just close the terminal and hope. Closing usually works because the session persists, but detaching cleanly is a better habit and avoids confusion about what is still attached. - Copy mode is prefix then
[, and getting text out of a remote pane into your local clipboard is genuinely awkward across SSH. I gave up on cleverness and mostly use it for scrolling and searching scrollback with/, which is reason enough on its own. - Nesting tmux inside tmux happens the moment you SSH from a tmux session into another host running tmux. The inner one steals your prefix. Sending the prefix twice (
C-a C-awith my config) reaches the inner session. It is confusing the first time and obvious forever after.
Where it stops being optional
For interactive work, tmux is a nicety. For long-running or fragile work on a remote host, it is the difference between an inconvenience and a real problem. Anything that takes longer than my patience for staring at a connection, a database migration, a big build, a dd to a slow disk, goes inside a named tmux session before it starts. If the line drops, I shrug and reattach. The process never knew anything happened.
I will not pretend it replaces everything. For some jobs a proper job scheduler or a systemd unit is the right answer, because then nobody needs to be attached at all. But for the messy interactive middle ground, the bit where you are doing something by hand and watching it, tmux is the tool that means a flaky connection costs you a reattach instead of an afternoon. Three years late to it, and the only regret is the sessions I lost before I started.