Skip to content

Commit

Permalink
Restoring pane title
Browse files Browse the repository at this point in the history
  • Loading branch information
c3r34lk1ll3r committed May 7, 2020
1 parent 327c048 commit 5c69748
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
9 changes: 5 additions & 4 deletions scripts/restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")"
Expand All @@ -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")
}

Expand Down Expand Up @@ -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")"
Expand All @@ -308,15 +309,15 @@ 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"
done
}

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
Expand Down
8 changes: 5 additions & 3 deletions scripts/save.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ pane_format() {
format+="#{pane_pid}"
format+="${delimiter}"
format+="#{history_size}"
format+="${delimiter}"
format+="#{pane_title}"
echo "$format"
}

Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 5c69748

Please sign in to comment.