Been using tmux resurrect for awhile now and I love it...one thing occurs to me though: does anyone have a hack to automatically save my tmux session on disconnect?
Edit: ahha, not exactly what I asked for, but linked on the tmux-resurrect page is tmux-continuum, automatic saving of tmux sessions. Perfect for me.
Wait... what? That's the whole point of tmux. As far as I know there's no such thing as 'saving'. They're automatically saved. Unless you're on a shared computer? If so... here's a solution I wrote up a while ago:
---
title: Tmux on a shared server
---
Normally, tmux stores its session sockets in the /tmp directory. This
is bad news when trying to run tmux on a shared computer (e.g. shared
compute nodes) since the tmp directory is probably cleared on every
login. To get around this tmux offers a way to store session sockets
in alternative locations. How to use this isn't entirely clear in the
man page though, so I'll outline it here. First, I'll create a
directory to store the socket with ``mkdir ~/.tmux.socket'`{.bash}.
Tmux stores new session sockets in the tmp directory so we must change
that when we start tmux:
TMPDIR=~/.tmux.socket tmux
and to attach to this socket we use the `-S`{.bash} option and glob to
the socket (defaulted to be named `default`{.bash})
tmux -S ~/.tmux.socket/*/default attach
Here are some aliases to put into your shell config file to help:
alias tmux-start="TMPDIR=~/.tmux.socket tmux"
alias tmux-attach="tmux -S ~/.tmux.socket/*/default attach"
Edit: ahha, not exactly what I asked for, but linked on the tmux-resurrect page is tmux-continuum, automatic saving of tmux sessions. Perfect for me.