Unverified Commit b502572a authored by Bruno Sutic's avatar Bruno Sutic
Browse files

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

parent 1c8efb03
......@@ -6,6 +6,7 @@
- save and restore grouped sessions (used with multi-monitor workflow)
- save and restore active and alternate windows in grouped sessions
- 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
- add support for restoring neovim sessions
......
......@@ -195,8 +195,14 @@ restore_active_and_alternate_windows_for_grouped_sessions() {
local grouped_session="$1"
echo "$grouped_session" |
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}"
tmux switch-client -t "${grouped_session}:${active_window_index}"
alternate_window_index="$(remove_first_char "$alternate_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
}
......
......@@ -142,7 +142,7 @@ dump_grouped_sessions() {
# this session "points" to the original session
active_window_index="$(get_active_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
done
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment