I used to lose work to dropped connections. Not files, nothing that dramatic, but state: the half-finished migration paused at a prompt, the long rsync three hours into a transfer, the tail I was watching for the one log line that mattered. The train would go through a tunnel, the laptop lid would close, the VPN would hiccup, and the SSH session would die taking the foreground process with it. tmux fixed that years ago and I have never gone back.
The trick is simple and it took me far too long to internalise. The terminal multiplexer runs on the remote host, not on my laptop. My SSH connection is just a window onto it. When the connection drops, the window closes but the session keeps running on the server, blissfully unaware that I have gone anywhere. I reconnect, reattach, and I am exactly where I was, mid-command and all.
The entire workflow is two commands. On arrival at a box where I am going to do anything that lasts longer than a few seconds:
$ ssh server
$ tmux new -s work
And when the connection inevitably dies and I come back:
$ ssh server
$ tmux attach -t work
That is genuinely the whole of it. The migration is still paused at its prompt. The rsync is still running. The tail is still tailing. Nothing knew the network had blinked because, from the server's point of view, nothing had: the processes never lost their controlling terminal, because their controlling terminal lives on the server too.
My one piece of muscle memory worth passing on is to name the session. A bare tmux new gives you "0", and "1", and "2", and a week later you are squinting at tmux ls trying to remember which anonymous number had the thing you cared about. Naming it work or deploy or the ticket number costs nothing and means tmux attach -t deploy always lands you in the right place.
There is a deeper point hiding in here, which is that the multiplexer decouples the work from the connection, and once you see that you start wanting it everywhere. The session is the durable thing. The connection is disposable, and treating it as disposable is liberating: I close the lid without a second thought now, because closing the lid costs me nothing. The work is somewhere else, patiently waiting, exactly where I left it.