7 Commits

8 changed files with 130 additions and 8 deletions

View File

@ -2,6 +2,11 @@
### master ### master
### v1.0.0, 2014-08-30
- show spinner during the save process
- add screencast script
- make default program running list even more conservative
### v0.4.0, 2014-08-29 ### v0.4.0, 2014-08-29
- change plugin name to `tmux-resurrect`. Change all the variable names. - change plugin name to `tmux-resurrect`. Change all the variable names.

View File

@ -9,11 +9,15 @@ configuration and continuous updates as your workflow evolves or you start new
projects. projects.
`tmux-resurrect` saves all the little details from tmux environment so it `tmux-resurrect` saves all the little details from tmux environment so it
can be completely restored after a system restart. No configuration is required. can be completely restored after a system restart (or when you feel like it).
You should feel like you never quit tmux. No configuration is required. You should feel like you never quit tmux.
It even (optionally) [restores vim sessions](#restoring-vim-sessions)! It even (optionally) [restores vim sessions](#restoring-vim-sessions)!
### Screencast
[![screencast screenshot](/video/screencast_img.png)](https://vimeo.com/104763018)
### Key bindings ### Key bindings
- `prefix + Alt-s` - save - `prefix + Alt-s` - save
@ -72,7 +76,7 @@ You should now be able to use the plugin.
Configuration is not required - but it enables extra features. Configuration is not required - but it enables extra features.
Only a conservative list of programs is restored by default:<br/> Only a conservative list of programs is restored by default:<br/>
`vi vim emacs man less more tail top htop irssi irb pry "~rails console"`. `vi vim emacs man less more tail top htop irssi`.
Open a github issue if you think some other program should be on the default list. Open a github issue if you think some other program should be on the default list.
- Restore additional programs with the setting in `.tmux.conf`: - Restore additional programs with the setting in `.tmux.conf`:
@ -85,7 +89,7 @@ Open a github issue if you think some other program should be on the default lis
- Start with tilde to restore a program whose process contains target name: - Start with tilde to restore a program whose process contains target name:
set -g @resurrect-processes 'some_program "~rails server"' set -g @resurrect-processes 'irb pry "~rails server" "~rails console"'
- Don't restore any programs: - Don't restore any programs:

View File

@ -192,7 +192,7 @@ restore_active_and_alternate_sessions() {
main() { main() {
if supported_tmux_version_ok && check_saved_session_exists; then if supported_tmux_version_ok && check_saved_session_exists; then
start_spinner start_spinner "Restoring..." "Tmux restore complete!"
restore_all_panes restore_all_panes
restore_pane_layout_for_each_window >/dev/null 2>&1 restore_pane_layout_for_each_window >/dev/null 2>&1
restore_all_pane_processes restore_all_pane_processes

View File

@ -4,6 +4,7 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$CURRENT_DIR/scripts/variables.sh" source "$CURRENT_DIR/scripts/variables.sh"
source "$CURRENT_DIR/helpers.sh" source "$CURRENT_DIR/helpers.sh"
source "$CURRENT_DIR/spinner_helpers.sh"
pane_format() { pane_format() {
local delimiter=$'\t' local delimiter=$'\t'
@ -96,12 +97,14 @@ save_all() {
dump_windows >> $resurrect_file_path dump_windows >> $resurrect_file_path
dump_state >> $resurrect_file_path dump_state >> $resurrect_file_path
ln -fs "$resurrect_file_path" "$(last_resurrect_file)" ln -fs "$resurrect_file_path" "$(last_resurrect_file)"
display_message "Tmux environment saved!"
} }
main() { main() {
if supported_tmux_version_ok; then if supported_tmux_version_ok; then
start_spinner "Saving..." "Tmux environment saved!"
save_all save_all
stop_spinner
display_message "Tmux environment saved!"
fi fi
} }
main main

View File

@ -1,5 +1,5 @@
start_spinner() { start_spinner() {
$CURRENT_DIR/tmux_spinner.sh "Restoring tmux..." "Tmux restore complete!" & $CURRENT_DIR/tmux_spinner.sh "$1" "$2" &
export SPINNER_PID=$! export SPINNER_PID=$!
} }

View File

@ -7,7 +7,7 @@ restore_option="@resurrect-restore"
# default processes that are restored # default processes that are restored
default_proc_list_option="@resurrect-default-processes" default_proc_list_option="@resurrect-default-processes"
default_proc_list='vi vim emacs man less more tail top htop irssi irb pry "~rails console"' default_proc_list='vi vim emacs man less more tail top htop irssi'
# User defined processes that are restored # User defined processes that are restored
# 'false' - nothing is restored # 'false' - nothing is restored

BIN
video/screencast_img.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

110
video/script.md Normal file
View File

@ -0,0 +1,110 @@
# Screencast script
1. Intro
========
Let's demo tmux resurrect plugin.
Tmux resurrect enables persisting tmux sessions, so it can survive the dreaded
system restarts.
The benefit is uninterrupted workflow with no configuration required.
2. Working session
==================
Script
------
Let me show you what I have in this tmux demo session.
First of all, I have vim open and it has a couple files loaded.
Then there's a tmux window with a couple splits in various directories across
the system.
Next window contains tmux man page,
and then there's `htop` program.
And this is just one of many projects I'm currently running.
Actions
-------
- blank tmux window
- vim
- `ls` to show open files
- multiple pane windows (3)
- man tmux
- htop
- psql
- show a list of session
3. Saving the environment
=========================
Script
------
With vanilla tmux, when I restart the computer this whole environment will be
lost and I'll have to invest time to restore it.
tmux resurrect gives you the ability to persist everything with
prefix plus alt-s.
Now tmux environment is saved and I can safely shut down tmux with a
kill server command.
Actions
-------
- prefix + M-s
- :kill-server
4. Restoring the environment
============================
Script
------
At this point restoring everything back is easy.
I'll fire up tmux again. Notice it's completely empty.
Now, I'll press prefix plus alt-r and everything will restore.
Let's see how things look now.
First of all, I'm back to the exact same window I was in when the environment
was saved. Second - you can see the `htop` program was restored.
Going back there's tmux man page
a window with multiple panes with the exact same layout as before
and vim.
tmux resurrect takes special care of vim. By leveraging vim's sessions, it
preserves vim's split windows, open files, even the list of files edited before.
Check out the project readme for more details about special treatment for vim.
That was just one of the restored tmux sessions. If I open tmux session list you
can see all the other projects are restored as well.
When you see all these programs running you might be concerned that this plugin
started a lot of potentially destructive processes.
For example, when you restore tmux you don't want to accidentally start backups,
resource intensive or sensitive programs.
There's no need to be worried though. By default, this plugin starts only a
conservative list of programs like vim, less, tail, htop and similar.
This list of programs restored by default is in the project readme. Also, you
can easily add more programs to it.
If you feel paranoid, there's an option that prevents restoring any program.
Actions
-------
- tmux
- prefix + M-r
- open previous windows
- in vim hit :ls
- prefix + s for a list of panes
5. Outro
========
That's it for this demo. I hope you'll find tmux resurrect useful.