mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-12-22 23:08:49 +00:00
Save and restore active and alternate windows for grouped sessions
This commit is contained in:
parent
5dc22a4a9b
commit
95ec3c1d9b
@ -4,6 +4,7 @@
|
||||
- add link to the wiki page for "first pane/window issue" to the README as well
|
||||
as other tweaks
|
||||
- save and restore grouped sessions (used with multi-monitor workflow)
|
||||
- save and restore active and alternate windows in grouped sessions
|
||||
|
||||
### v1.5.0, 2014-11-09
|
||||
- add support for restoring neovim sessions
|
||||
|
@ -186,15 +186,25 @@ restore_active_pane_for_each_window() {
|
||||
restore_grouped_session() {
|
||||
local grouped_session="$1"
|
||||
echo "$grouped_session" |
|
||||
while IFS=$'\t' read line_type grouped_session original_session; do
|
||||
while IFS=$'\t' read line_type grouped_session original_session alternate_window active_window; do
|
||||
TMUX="" tmux -S "$(tmux_socket)" new-session -d -s "$grouped_session" -t "$original_session"
|
||||
done
|
||||
}
|
||||
|
||||
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}"
|
||||
done
|
||||
}
|
||||
|
||||
restore_grouped_sessions() {
|
||||
while read line; do
|
||||
if is_line_type "grouped_session" "$line"; then
|
||||
restore_grouped_session "$line"
|
||||
restore_active_and_alternate_windows_for_grouped_sessions "$line"
|
||||
fi
|
||||
done < $(last_resurrect_file)
|
||||
}
|
||||
@ -227,7 +237,7 @@ main() {
|
||||
# below functions restore exact cursor positions
|
||||
restore_active_pane_for_each_window
|
||||
restore_zoomed_windows
|
||||
restore_grouped_sessions
|
||||
restore_grouped_sessions # also restores active and alt windows for grouped sessions
|
||||
restore_active_and_alternate_windows
|
||||
restore_active_and_alternate_sessions
|
||||
stop_spinner
|
||||
|
@ -114,6 +114,18 @@ save_shell_history() {
|
||||
fi
|
||||
}
|
||||
|
||||
get_active_window_index() {
|
||||
local session_name="$1"
|
||||
tmux list-windows -t "$session_name" -F "#{window_flags} #{window_index}" |
|
||||
awk '$1 ~ /\*/ { print $2; }'
|
||||
}
|
||||
|
||||
get_alternate_window_index() {
|
||||
local session_name="$1"
|
||||
tmux list-windows -t "$session_name" -F "#{window_flags} #{window_index}" |
|
||||
awk '$1 ~ /-/ { print $2; }'
|
||||
}
|
||||
|
||||
dump_grouped_sessions() {
|
||||
local current_session_group=""
|
||||
local original_session
|
||||
@ -128,7 +140,9 @@ dump_grouped_sessions() {
|
||||
current_session_group="$session_group"
|
||||
else
|
||||
# this session "points" to the original session
|
||||
echo "grouped_session${d}${session_name}${d}${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}"
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user