@@ -76,6 +76,14 @@ is_restoring_pane_contents() {
76
76
[ " $RESTORE_PANE_CONTENTS " == " true" ]
77
77
}
78
78
79
+ restored_session_0_true () {
80
+ RESTORED_SESSION_0=" true"
81
+ }
82
+
83
+ has_restored_session_0 () {
84
+ [ " $RESTORED_SESSION_0 " == " true" ]
85
+ }
86
+
79
87
window_exists () {
80
88
local session_name=" $1 "
81
89
local window_number=" $2 "
@@ -174,6 +182,9 @@ restore_pane() {
174
182
dir=" $( remove_first_char " $dir " ) "
175
183
window_name=" $( remove_first_char " $window_name " ) "
176
184
pane_full_command=" $( remove_first_char " $pane_full_command " ) "
185
+ if [ " $session_name " == " 0" ]; then
186
+ restored_session_0_true
187
+ fi
177
188
if pane_exists " $session_name " " $window_number " " $pane_index " ; then
178
189
tmux rename-window -t " $window_number " " $window_name "
179
190
if is_restoring_from_scratch; then
@@ -270,6 +281,16 @@ restore_all_panes() {
270
281
fi
271
282
}
272
283
284
+ handle_session_0 () {
285
+ if is_restoring_from_scratch && ! has_restored_session_0; then
286
+ local current_session=" $( tmux display -p " #{client_session}" ) "
287
+ if [ " $current_session " == " 0" ]; then
288
+ tmux switch-client -n
289
+ fi
290
+ tmux kill-session -t " 0"
291
+ fi
292
+ }
293
+
273
294
restore_pane_layout_for_each_window () {
274
295
\g rep ' ^window' $( last_resurrect_file) |
275
296
while IFS=$d read line_type session_name window_number window_active window_flags window_layout; do
@@ -353,6 +374,7 @@ main() {
353
374
start_spinner " Restoring..." " Tmux restore complete!"
354
375
execute_hook " pre-restore-all"
355
376
restore_all_panes
377
+ handle_session_0
356
378
restore_pane_layout_for_each_window > /dev/null 2>&1
357
379
execute_hook " pre-restore-history"
358
380
if save_shell_history_option_on; then
0 commit comments