tmux Continuum is a plugin that automatically saves your tmux sessions and restores them when you restart your terminal.
Here’s a tmux Continuum session in action.
# Start a new tmux session
$ tmux new-session -s myproject
# Inside tmux, split the window and open a few more panes
$ tmux split-window -v
$ tmux split-window -h
$ tmux select-pane -t 0
$ tmux split-window -h
# Open a few different programs in the panes
# Pane 0: tail -f /var/log/syslog
# Pane 1: vim myapp/main.py
# Pane 2: git status
# Pane 3: irssi
# Detach from the session
$ tmux detach
# Close the terminal and reopen it later
$ tmux attach-session -t myproject
Notice how all your windows, panes, and even the programs running within them are restored exactly as you left them. This is incredibly useful for maintaining your workflow across reboots or when you need to switch between machines.
The problem tmux Continuum solves is the ephemeral nature of terminal sessions. Normally, when you close your terminal, all your running processes within that session are terminated. You have to manually recreate your windows, panes, and restart your applications. This can be a significant productivity drain, especially for complex projects involving multiple services, logs, and development tools.
tmux Continuum works by periodically saving the state of your tmux session to a file. This state includes the layout of your windows and panes, the current working directory of each pane, and crucially, the command that was running in each pane. When you start a new tmux server or attach to an existing one, Continuum checks for a saved session. If it finds one, it restores it by recreating the tmux windows and panes and, where possible, restarting the commands that were running.
The core configuration for tmux Continuum involves specifying how often sessions should be saved and where they should be stored.
# Save session every 15 minutes
set -g @continuum-save-interval '15'
# Store sessions in ~/.tmux/resurrect/
set -g @continuum-restore-path '~/.tmux/resurrect/'
# Tell tmux Continuum to use tmux-resurrect for saving/restoring
set -g @continuum-plugin 'tmux-resurrect'
To enable Continuum, you’ll typically need a plugin manager like tpm (tmux Plugin Manager).
First, install tpm if you haven’t already. Add this to your ~/.tmux.conf:
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
# Initialize TMUX plugin manager
run '~/.tmux/plugins/tpm/tpm'
Then, restart tmux and press Prefix + I (that’s usually Ctrl+b followed by I) to install the plugins.
The most surprising thing about tmux Continuum is how it handles restoring complex application states. It doesn’t just restore the command; it attempts to restore the running process itself. For many command-line applications like Vim, Emacs, or even simple shell commands, Continuum can send signals to reattach to the existing process, effectively picking up exactly where you left off, including unsaved buffers in editors.
The next concept you’ll likely explore is how to manage multiple, distinct saved sessions and how to manually trigger saves or restores.