Ramblings of an aging IT geek
← Ramblings of an aging IT geek
tooling

tmux, and never losing a session to a dropped ssh again

Why I run every remote shell inside tmux now, and the handful of habits that make a detached session something you actually come back to.

A keyboard in front of a terminal

The first rule of doing anything long-running over SSH: start it inside tmux. I learned this the way most people learn it, by watching a four-hour rsync die because my laptop went to sleep on the train and the connection dropped. The work was gone. The session was gone. The only thing that survived was the lesson.

Now every remote box gets the same reflex. SSH in, tmux new -s work, and do everything inside that. If the connection drops, the session keeps running on the server, detached and patient. You reconnect, run tmux attach -t work, and you're back exactly where you were: same scrollback, same running jobs, same half-typed command.

That's the whole pitch, really. The rest is comfort. I split panes with the prefix and % or ", so I can watch a log in one and poke at things in another. Named sessions mean I can keep a couple of jobs on the same box without confusing myself: tmux ls lists what's running.

The only configuration I bother with is remapping the prefix from Ctrl-b to Ctrl-a, because my fingers came from screen and never forgave the change. Two lines in ~/.tmux.conf and it's done.

I don't use a tenth of what tmux can do. I don't need to. Detach, reattach, and the train can do what it likes.