Restore active and alternate window for each session

Closes #12
This commit is contained in:
Bruno Sutic 2014-08-26 19:16:51 +02:00
parent ecc42c5a56
commit 8166fa2602
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
2 changed files with 10 additions and 0 deletions

View File

@ -4,6 +4,7 @@
- save and restore current and alternate session - save and restore current and alternate session
- fix a bug with non-existing window names - fix a bug with non-existing window names
- restore active pane for each window that has multiple panes - restore active pane for each window that has multiple panes
- restore active and alternate window for each session
### v0.0.2, 2014-08-26 ### v0.0.2, 2014-08-26
- saving a new session does not remove the previous one - saving a new session does not remove the previous one

View File

@ -112,6 +112,14 @@ restore_active_pane_for_each_window() {
done 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() { restore_active_and_alternate_sessions() {
while read line; do while read line; do
if is_line_type "state" "$line"; then if is_line_type "state" "$line"; then
@ -125,6 +133,7 @@ main() {
check_saved_session_exists check_saved_session_exists
restore_all_sessions restore_all_sessions
restore_active_pane_for_each_window restore_active_pane_for_each_window
restore_active_and_alternate_windows
restore_active_and_alternate_sessions restore_active_and_alternate_sessions
display_message "Restored all Tmux sessions!" display_message "Restored all Tmux sessions!"
fi fi