Skip to content

Commit 79c83cb

Browse files
committed
Resurrect pane options
1 parent a05f11e commit 79c83cb

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

scripts/restore.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,14 @@ restore_window_options() {
395395
done
396396
}
397397

398+
restore_pane_options() {
399+
\grep '^option_pane' $(last_resurrect_file) |
400+
while IFS=$d read line_type session_name windows_index pane_index option value; do
401+
value=$(echo $value | sed 's/"\(.*\)"/\1/')
402+
tmux set-option -p -t "${session_name}:${windows_index}.${pane_index}" "${option}" "${value}"
403+
done
404+
}
405+
398406
# A cleanup that happens after 'restore_all_panes' seems to fix fish shell
399407
# users' restore problems.
400408
cleanup_restored_pane_contents() {
@@ -421,6 +429,7 @@ main() {
421429
restore_active_and_alternate_sessions
422430
restore_session_options
423431
restore_window_options
432+
restore_pane_options
424433
cleanup_restored_pane_contents
425434
execute_hook "post-restore-all"
426435
stop_spinner

scripts/save.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,18 @@ window_option_format() {
103103
echo "$format"
104104
}
105105

106+
pane_option_format() {
107+
local format
108+
format+="option_pane"
109+
format+="${delimiter}"
110+
format+="#{session_name}"
111+
format+="${delimiter}"
112+
format+="#{window_index}"
113+
format+="${delimiter}"
114+
format+="#{pane_index}"
115+
echo "$format"
116+
}
117+
106118
dump_panes_raw() {
107119
tmux list-panes -a -F "$(pane_format)"
108120
}
@@ -291,6 +303,20 @@ dump_window_options() {
291303
done
292304
}
293305

306+
dump_pane_options() {
307+
tmux list-panes -a -F "$(pane_option_format)" |
308+
while IFS=$d read line_type session_name window_index pane_index; do
309+
# not saving panes from grouped sessions
310+
if is_session_grouped "$session_name" || is_window_linked "$session_name" "$window_index"; then
311+
continue
312+
fi
313+
tmux show-options -p -t "${session_name}:${window_index}.${pane_index}" | sed "s/ /$d/" |
314+
while IFS=$d read option value; do
315+
echo "${line_type}${d}${session_name}${d}${window_index}${d}${pane_index}${d}${option}$d${value}"
316+
done
317+
done
318+
}
319+
294320
dump_state() {
295321
tmux display-message -p "$(state_format)"
296322
}
@@ -326,6 +352,7 @@ save_all() {
326352
dump_state >> "$resurrect_file_path"
327353
dump_session_options >> "$resurrect_file_path"
328354
dump_window_options >> "$resurrect_file_path"
355+
dump_pane_options >> "$resurrect_file_path"
329356
execute_hook "post-save-layout" "$resurrect_file_path"
330357
if files_differ "$resurrect_file_path" "$last_resurrect_file"; then
331358
ln -fs "$(basename "$resurrect_file_path")" "$last_resurrect_file"

0 commit comments

Comments
 (0)