Commit 80adb917 authored by A Farzat's avatar A Farzat
Browse files

Maintain the value of automatic-rename

When the session is restored, the windows are renamed to their original
names switching off automatic-rename, which can be undesirable.
Therefore the value of automatic-rename is now saved for each window and
restored after the renaming.

If the value is set, that value is saved and then applied. Otherwise, a
placeholder of ':' is placed instead, in which case the local option is
unset for that window (as it originally was).
parent 716b9581
...@@ -292,10 +292,15 @@ handle_session_0() { ...@@ -292,10 +292,15 @@ handle_session_0() {
fi fi
} }
restore_pane_layout_for_each_window() { restore_pane_layout_and_autonaming_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 automatic_rename; do
tmux select-layout -t "${session_name}:${window_number}" "$window_layout" tmux select-layout -t "${session_name}:${window_number}" "$window_layout"
if [ "${automatic_rename}" = ":" ]; then
tmux set-option -u -t "${session_name}:${window_number}" automatic-rename
tmux set-option -t "${session_name}:${window_number}" automatic-rename "$automatic_rename"
done done
} }
...@@ -376,7 +381,7 @@ main() { ...@@ -376,7 +381,7 @@ main() {
execute_hook "pre-restore-all" execute_hook "pre-restore-all"
restore_all_panes restore_all_panes
handle_session_0 handle_session_0
restore_pane_layout_for_each_window >/dev/null 2>&1 restore_pane_layout_and_autonaming_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
restore_shell_history restore_shell_history
...@@ -245,7 +245,10 @@ dump_windows() { ...@@ -245,7 +245,10 @@ dump_windows() {
if is_session_grouped "$session_name"; then if is_session_grouped "$session_name"; then
continue continue
fi fi
echo "${line_type}${d}${session_name}${d}${window_index}${d}${window_active}${d}${window_flags}${d}${window_layout}" automatic_rename="$(tmux show-window-options -vt "${session_name}:${window_index}" automatic-rename)"
# If the option was unset, place the ":" placeholder instead.
[ -z "${automatic_rename}" ] && automatic_rename=":"
echo "${line_type}${d}${session_name}${d}${window_index}${d}${window_active}${d}${window_flags}${d}${window_layout}${d}${automatic_rename}"
done 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