/tmux-save-sessions

save and restore tmux sessions in bash

Primary LanguageShellMIT LicenseMIT

tmux-save-sessions

Save and restore tmux sessions in bash

There are many ways to tmuxinate, but I just want a bash script of my tmux sessions.

Usage

./tmux-save-sessions

All sessions, windows, panes, running commands and layouts get saved as a bash script in the current directory named sessions-${timestamp}.sh

To restore a session, execute the generated script.

  ./sessions-2014-08-12-4423.sh

Run ./tmux-save-sessions multiple times to save different snapshots of your sessions.

Requirements

tmux 1.9
bash




Inspired by all the other scripts out there and this snippet from the tmux manpage:

In addition, select-layout may be used to apply a previously used layout
 - the list-windows command displays the layout of each window in a form
 suitable for use with select-layout.  For example:

       $ tmux list-windows
       0: ksh [159x48]
           layout: bb62,159x48,0,0{79x48,0,0,79x48,80,0}
       $ tmux select-layout bb62,159x48,0,0{79x48,0,0,79x48,80,0}

 tmux automatically adjusts the size of the layout for the current window
 size.  Note that a layout cannot be applied to a window with more panes
 than that from which the layout was originally defined.