diff --git a/CHANGELOG.md b/CHANGELOG.md index ac4838c..62c6f9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - save and restore current and alternate session - fix a bug with non-existing window names - restore active pane for each window that has multiple panes +- restore active and alternate window for each session ### v0.0.2, 2014-08-26 - saving a new session does not remove the previous one diff --git a/scripts/session_restorer.sh b/scripts/session_restorer.sh index 91bfe8e..27d22fc 100755 --- a/scripts/session_restorer.sh +++ b/scripts/session_restorer.sh @@ -112,6 +112,14 @@ restore_active_pane_for_each_window() { done } +restore_active_and_alternate_windows() { + awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $6 ~ /[*-]/ { print $2, $5, $3; }' $(last_session_path) | + sort -u | + while IFS=$'\t' read session_name active_window window_number; do + tmux switch-client -t "${session_name}:${window_number}" + done +} + restore_active_and_alternate_sessions() { while read line; do if is_line_type "state" "$line"; then @@ -125,6 +133,7 @@ main() { check_saved_session_exists restore_all_sessions restore_active_pane_for_each_window + restore_active_and_alternate_windows restore_active_and_alternate_sessions display_message "Restored all Tmux sessions!" fi