DEV Community

Dang Hoang Nhu Nguyen
Dang Hoang Nhu Nguyen

Posted on

[BTY] Day 12: Auto resurrecting tmux sessions

Tmux is great, except when you have to restart the computer. You lose all the running programs, working directories, pane layouts etc.

tmux-resurrect is a tool to persist a tmux environment across system restarts.

But, you have to manually save an entire tmux session or restore the session.

tmux-continuum comes as a cure because it continuously saves your tmux environment at regular intervals and automatically restores it when tmux is started.

Checkout here: https://github.com/tmux-plugins/tmux-continuum

# In ~/.tmux.conf
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'

# https://github.com/tmux-plugins/tmux-continuum/issues/48#issuecomment-527336993
set -g @continuum-save-interval '15'

# Option to display current status of tmux continuum in tmux status line. 
set -g status-right 'Continuum status: #{continuum_status}'

# Other examples:
# set -g @plugin 'github_username/plugin_name'
# set -g @plugin 'github_username/plugin_name#branch'
# set -g @plugin 'git@github.com:user/plugin'
# set -g @plugin 'git@bitbucket.com:user/plugin'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'

# Restart / reload TMUX env using : Prefix + I or "tmux source ~/.tmux.conf"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)