From 5c69748392decb52383c41edb0294ba68d9f5025 Mon Sep 17 00:00:00 2001 From: c3r34lk1ll3r Date: Thu, 7 May 2020 10:41:57 +0200 Subject: [PATCH] Restoring pane title --- scripts/restore.sh | 9 +++++---- scripts/save.sh | 8 +++++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/scripts/restore.sh b/scripts/restore.sh index c1a4e499..ea45f369 100755 --- a/scripts/restore.sh +++ b/scripts/restore.sh @@ -169,7 +169,7 @@ new_pane() { restore_pane() { local pane="$1" - while IFS=$d read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command pane_full_command; do + while IFS=$d read line_type session_name window_number window_name window_active window_flags pane_index pane_title dir pane_active pane_command pane_full_command; do dir="$(remove_first_char "$dir")" window_name="$(remove_first_char "$window_name")" pane_full_command="$(remove_first_char "$pane_full_command")" @@ -194,6 +194,7 @@ restore_pane() { else new_session "$session_name" "$window_number" "$window_name" "$dir" "$pane_index" fi + tmux select-pane -t "$session_name":"$window_number"."$pane_index" -T "${pane_title}" done < <(echo "$pane") } @@ -298,7 +299,7 @@ restore_shell_history() { restore_all_pane_processes() { if restore_pane_processes_enabled; then local pane_full_command - awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $11 !~ "^:$" { print $2, $3, $7, $8, $11; }' $(last_resurrect_file) | + awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $11 !~ "^:$" { print $2, $3, $7, $9, $12; }' $(last_resurrect_file) | while IFS=$d read -r session_name window_number pane_index dir pane_full_command; do dir="$(remove_first_char "$dir")" pane_full_command="$(remove_first_char "$pane_full_command")" @@ -308,7 +309,7 @@ restore_all_pane_processes() { } restore_active_pane_for_each_window() { - awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $9 == 1 { print $2, $3, $7; }' $(last_resurrect_file) | + awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $10 == 1 { print $2, $3, $7; }' $(last_resurrect_file) | while IFS=$d read session_name window_number active_pane; do tmux switch-client -t "${session_name}:${window_number}" tmux select-pane -t "$active_pane" @@ -316,7 +317,7 @@ restore_active_pane_for_each_window() { } restore_zoomed_windows() { - awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $6 ~ /Z/ && $9 == 1 { print $2, $3; }' $(last_resurrect_file) | + awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $6 ~ /Z/ && $10 == 1 { print $2, $3; }' $(last_resurrect_file) | while IFS=$d read session_name window_number; do tmux resize-pane -t "${session_name}:${window_number}" -Z done diff --git a/scripts/save.sh b/scripts/save.sh index 9d80af70..28c2a270 100755 --- a/scripts/save.sh +++ b/scripts/save.sh @@ -50,6 +50,8 @@ pane_format() { format+="#{pane_pid}" format+="${delimiter}" format+="#{history_size}" + format+="${delimiter}" + format+="#{pane_title}" echo "$format" } @@ -227,14 +229,14 @@ fetch_and_dump_grouped_sessions(){ dump_panes() { local full_command dump_panes_raw | - while IFS=$d read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command pane_pid history_size; do + while IFS=$d read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command pane_pid history_size pane_title; do # not saving panes from grouped sessions if is_session_grouped "$session_name"; then continue fi full_command="$(pane_full_command $pane_pid)" dir=$(echo $dir | sed 's/ /\\ /') # escape all spaces in directory path - echo "${line_type}${d}${session_name}${d}${window_number}${d}${window_name}${d}${window_active}${d}${window_flags}${d}${pane_index}${d}${dir}${d}${pane_active}${d}${pane_command}${d}:${full_command}" + echo "${line_type}${d}${session_name}${d}${window_number}${d}${window_name}${d}${window_active}${d}${window_flags}${d}${pane_index}${d}${pane_title}${d}${dir}${d}${pane_active}${d}${pane_command}${d}:${full_command}" done } @@ -313,7 +315,7 @@ main() { start_spinner "Saving..." "Tmux environment saved!" fi save_all - if show_output; then + if show_output; then stop_spinner display_message "Tmux environment saved!" fi