Skip to content

A python module that works with Tmux to save and restore tmux sessions across reboots

License

Notifications You must be signed in to change notification settings

arjunghoshal/tmux-restore

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tmux-restore

Overview

Works with tmux to save and restore sessions across reboots. Sessions are stored at ~/.tmux-restore.

Features

  • 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

To Do

  • Save environment variables
  • Add configuration option for session file
  • Add configuration option for adding running programs to save

Set Up

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!

Usage

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

About

A python module that works with Tmux to save and restore tmux sessions across reboots

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published