Restoring TMUX sessions after a system reboot with tmux-resurrect

Created Updated
3 min read 491 words

If you’re a frequent user of tmux, you know how frustrating it can be to lose your sessions after a system reboot. Fortunately, there’s a plugin called tmux-resurrect that can help you restore your sessions quickly and easily. In this article, we’ll go over how to use this plugin to restore your tmux sessions.

Prerequisites

Before we get started, there’s one prerequisite you need to meet: you must have the tmux plugin manager installed on your system. If you don’t have it installed, you can follow the instructions in our previous article to install it: [insert link to previous article].

Installing the tmux-resurrect Plugin

Once you have the tmux plugin manager installed, installing the tmux-resurrect plugin is a breeze. Simply run the following command in your terminal:

tmux install tmux-plugins/tmux-resurrect

This command will download and install the plugin. Once it’s installed, you can load it by running the following command:

tmux load-plugin tmux-resurrect

Configuring the Plugin

Before you can use the tmux-resurrect plugin, you need to configure it. To do this, run the following command:

tmux config-plugin tmux-resurrect

This will open up the plugin’s configuration file in your default editor. Add the following lines to the file:

# Save session on exit
set-option -g @plugin-resurrect-save-on-exit true

# Save session every 10 minutes
set-option -g @plugin-resurrect-save-interval 10m

# Load last saved session on start
set-option -g @plugin-resurrect-load-last-session true

These lines tell the plugin to save your sessions when you exit tmux, save your sessions every 10 minutes, and load the last saved session when you start tmux.

Saving Your Sessions

Now that the plugin is configured, you can start saving your sessions. Whenever you exit tmux, the plugin will save your current session to a file in the .tmux directory in your home directory. The file will be named session.timestamp, where timestamp is the current timestamp.

To save your session manually, you can run the following command:

tmux save-session

This will save your current session to a file in the .tmux directory.

Restoring Your Sessions

To restore a saved session, you can use the tmux resurrect command. For example, if you want to restore the last saved session, you can run the following command:

tmux resurrect -l

This will load the last saved session and restore it in the current tmux window. If you want to restore a specific session, you can use the following command:

tmux resurrect /path/to/session.timestamp

Replace /path/to/session.timestamp with the path to the session file you want to restore.

Conclusion

With the tmux-resurrect plugin, you can easily save and restore your tmux sessions after a system reboot. By following the instructions in this article, you’ll be able to configure the plugin and start saving your sessions right away. No more losing your progress or having to set up your windows and panes again – tmux-resurrect has got you covered.

Add comment below...

Please refresh the page if commenting system is not visible.