Works with tmux
to save and restore sessions across reboots. Sessions are stored at ~/.tmux-restore
.
- Save session windows, panes, and layouts automatically on detach/exit
- Automatically restore sessions on reboot
- Restores windows, panes, and layout
- Restores running processes for select programs:
- emacs/vi/
- vim/nvim
- Restores cursor location
- man
- less/more
- tail
- top/htop
- irssi/weechat/mutt
- ssh
- psql/mysql/sqlite3
- Save environment variables
- Add configuration option for session file
- Add configuration option for adding running programs to save
To install tmux-restore
, run the following:
pip install tmux-restore
Then, to restore your saved sessions on reboot, edit your .bashrc
file with the following content:
# colors...
# tmux-restore trigger
if ! tmux info &> /dev/null; then
if ! tmux ls &> /dev/null; then
(python3 -m tmux-restore &)
fi
fi
# aliases...
It is important that this is done above alias definition to avoid conflicts.
Finally, add the following content to either where the other aliases are defined in your .bashrc
file or to your .bash_aliases
file:
tmux() {
command tmux $*
(python3 -m tmux-restore save &)
}
This will ensure that your sessions save after you exit or detach from a tmux
session. Restart your shell to apply the effects.
Your tmux sessions will now restore themselves across reboots!
If you would like to save or restore your tmux
sessions manually:
# Save
python3 -m tmux-restore save
# Restore
python3 -m tmux-restore
# OR
python3 -m tmux-restore restore