Restore active and alternate windows only if they are present in the 'last' file

This commit is contained in:
Bruno Sutic 2015-02-09 16:11:49 +01:00
parent 1c8efb034a
commit b502572a07
No known key found for this signature in database
GPG Key ID: 66D96E4F2F7EF26C
3 changed files with 10 additions and 3 deletions

View File

@ -6,6 +6,7 @@
- save and restore grouped sessions (used with multi-monitor workflow) - save and restore grouped sessions (used with multi-monitor workflow)
- save and restore active and alternate windows in grouped sessions - save and restore active and alternate windows in grouped sessions
- if there are no grouped sessions, do not output empty line to "last" file - if there are no grouped sessions, do not output empty line to "last" file
- restore active and alternate windows only if they are present in the "last" file
### v1.5.0, 2014-11-09 ### v1.5.0, 2014-11-09
- add support for restoring neovim sessions - add support for restoring neovim sessions

View File

@ -195,8 +195,14 @@ restore_active_and_alternate_windows_for_grouped_sessions() {
local grouped_session="$1" local grouped_session="$1"
echo "$grouped_session" | echo "$grouped_session" |
while IFS=$'\t' read line_type grouped_session original_session alternate_window_index active_window_index; do while IFS=$'\t' read line_type grouped_session original_session alternate_window_index active_window_index; do
tmux switch-client -t "${grouped_session}:${alternate_window_index}" alternate_window_index="$(remove_first_char "$alternate_window_index")"
tmux switch-client -t "${grouped_session}:${active_window_index}" active_window_index="$(remove_first_char "$active_window_index")"
if [ -n "$alternate_window_index" ]; then
tmux switch-client -t "${grouped_session}:${alternate_window_index}"
fi
if [ -n "$active_window_index" ]; then
tmux switch-client -t "${grouped_session}:${active_window_index}"
fi
done done
} }

View File

@ -142,7 +142,7 @@ dump_grouped_sessions() {
# this session "points" to the original session # this session "points" to the original session
active_window_index="$(get_active_window_index "$session_name")" active_window_index="$(get_active_window_index "$session_name")"
alternate_window_index="$(get_alternate_window_index "$session_name")" alternate_window_index="$(get_alternate_window_index "$session_name")"
echo "grouped_session${d}${session_name}${d}${original_session}${d}${alternate_window_index}${d}${active_window_index}" echo "grouped_session${d}${session_name}${d}${original_session}${d}:${alternate_window_index}${d}:${active_window_index}"
fi fi
done done
} }