The trigger was a train. Two hours of patchy tethering, a long migration script running on a remote box, and an ssh session that dropped every time we went through a tunnel. The script kept running, because I'd had the sense to start it under tmux, but the version of me from three years ago would have lost the lot.
If you've not committed to tmux yet, this is the pitch: your shell sessions live on the server, not in your terminal. The link can die, your laptop can sleep, you can close the lid and go home, and the work carries on. When you come back you attach to the session and it's exactly where you left it, scrollback and all.
The whole workflow is two commands. Start or attach a named session:
tmux new -A -s work
The -A is the bit people miss. It means "attach if it exists, otherwise create it", so you can run that same line every time and never think about whether the session is already there.
After that it's the prefix key and a handful of bindings. I leave the prefix on the default Ctrl-b because I move between too many machines to retrain my fingers per host. The ones I use constantly:
prefix "andprefix %to split a pane horizontally and verticallyprefix arrowto move between panesprefix dto detach and walk awayprefix [to enter copy mode and actually scroll the buffer
My .tmux.conf is deliberately short. The only opinionated lines:
set -g history-limit 50000
set -g mouse on
set -g base-index 1
setw -g pane-base-index 1
The big scrollback has saved me more than once when a command spewed something useful and then a thousand lines of noise on top of it. Mouse mode I went back and forth on, since purists hate it, but being able to drag a pane border when I'm tired is worth the small loss of dignity.
The habit that actually matters isn't the config, though. It's running everything long under tmux by reflex, before you know whether you'll need it. The migration on the train didn't survive because I made a good decision on the train. It survived because I'd made the boring decision twenty minutes earlier, out of habit, when the connection was still fine.