Save and restore a tmux session
As the number of running commands has increased from one to four, I’ve needed a better way to manage all the running terminals. I’ve always wanted to give tmux
a try, and this was the perfect opportunity. But it takes a little time to run all the commands across different Git repositories so that my entire environment is ready for local development. What I needed was a way to save my session, and that’s exactly what the tmux-resurrect
plugin does.
Installation
To install a plugin (without the package manager, which I could not get working), clone the repository:
git clone https://github.com/tmux-plugins/tmux-resurrect ~/.tmux/plugins/tmux-resurrect
Then add the following line to your ~/.tmux.config
file:
run-shell ~/.tmux/plugins/tmux-resurrect/resurrect.tmux
Finally, reload tmux with:
tmux source-file ~/.tmux.config
Usage
Once I have a session configured the way I want, I need only type Ctrl-B Ctrl-s
to save it. Then, the next time I need to restore that session, I simply enter Ctrl-B Ctrl-r
.