mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-24 05:48:48 +00:00
Kill session 0 if it's not restored
This commit is contained in:
parent
78d67e4dcb
commit
5f5f9d8fd5
@ -29,6 +29,7 @@
|
|||||||
- Enable vim session strategy to work with custom session files,
|
- Enable vim session strategy to work with custom session files,
|
||||||
e.g. `vim -S Session1.vim`.
|
e.g. `vim -S Session1.vim`.
|
||||||
- Enable restoring command arguments for inline strategies with `*` character.
|
- Enable restoring command arguments for inline strategies with `*` character.
|
||||||
|
- Kill session "0" if it wasn't restored.
|
||||||
|
|
||||||
### v2.4.0, 2015-02-23
|
### v2.4.0, 2015-02-23
|
||||||
- add "tmux-test"
|
- add "tmux-test"
|
||||||
|
@ -76,6 +76,14 @@ is_restoring_pane_contents() {
|
|||||||
[ "$RESTORE_PANE_CONTENTS" == "true" ]
|
[ "$RESTORE_PANE_CONTENTS" == "true" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restored_session_0_true() {
|
||||||
|
RESTORED_SESSION_0="true"
|
||||||
|
}
|
||||||
|
|
||||||
|
has_restored_session_0() {
|
||||||
|
[ "$RESTORED_SESSION_0" == "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
window_exists() {
|
window_exists() {
|
||||||
local session_name="$1"
|
local session_name="$1"
|
||||||
local window_number="$2"
|
local window_number="$2"
|
||||||
@ -174,6 +182,9 @@ restore_pane() {
|
|||||||
dir="$(remove_first_char "$dir")"
|
dir="$(remove_first_char "$dir")"
|
||||||
window_name="$(remove_first_char "$window_name")"
|
window_name="$(remove_first_char "$window_name")"
|
||||||
pane_full_command="$(remove_first_char "$pane_full_command")"
|
pane_full_command="$(remove_first_char "$pane_full_command")"
|
||||||
|
if [ "$session_name" == "0" ]; then
|
||||||
|
restored_session_0_true
|
||||||
|
fi
|
||||||
if pane_exists "$session_name" "$window_number" "$pane_index"; then
|
if pane_exists "$session_name" "$window_number" "$pane_index"; then
|
||||||
tmux rename-window -t "$window_number" "$window_name"
|
tmux rename-window -t "$window_number" "$window_name"
|
||||||
if is_restoring_from_scratch; then
|
if is_restoring_from_scratch; then
|
||||||
@ -270,6 +281,16 @@ restore_all_panes() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handle_session_0() {
|
||||||
|
if is_restoring_from_scratch && ! has_restored_session_0; then
|
||||||
|
local current_session="$(tmux display -p "#{client_session}")"
|
||||||
|
if [ "$current_session" == "0" ]; then
|
||||||
|
tmux switch-client -n
|
||||||
|
fi
|
||||||
|
tmux kill-session -t "0"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
restore_pane_layout_for_each_window() {
|
restore_pane_layout_for_each_window() {
|
||||||
\grep '^window' $(last_resurrect_file) |
|
\grep '^window' $(last_resurrect_file) |
|
||||||
while IFS=$d read line_type session_name window_number window_active window_flags window_layout; do
|
while IFS=$d read line_type session_name window_number window_active window_flags window_layout; do
|
||||||
@ -353,6 +374,7 @@ main() {
|
|||||||
start_spinner "Restoring..." "Tmux restore complete!"
|
start_spinner "Restoring..." "Tmux restore complete!"
|
||||||
execute_hook "pre-restore-all"
|
execute_hook "pre-restore-all"
|
||||||
restore_all_panes
|
restore_all_panes
|
||||||
|
handle_session_0
|
||||||
restore_pane_layout_for_each_window >/dev/null 2>&1
|
restore_pane_layout_for_each_window >/dev/null 2>&1
|
||||||
execute_hook "pre-restore-history"
|
execute_hook "pre-restore-history"
|
||||||
if save_shell_history_option_on; then
|
if save_shell_history_option_on; then
|
||||||
|
Loading…
Reference in New Issue
Block a user