mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-21 11:58:49 +00:00
Merge pull request #431 from Hologos/feature/save-pane-title
Adds support for saving and restoring pane titles.
This commit is contained in:
commit
5b5e6ca7b1
@ -2,6 +2,7 @@
|
||||
|
||||
### master
|
||||
- Proper handling of `automatic-rename` window option.
|
||||
- save and restore tmux pane title (breaking change: you have to re-save to be able to properly restore!)
|
||||
|
||||
### v3.0.0, 2021-08-30
|
||||
- save and restore tmux pane contents (@laomaiweng)
|
||||
|
@ -170,12 +170,12 @@ new_pane() {
|
||||
tmux split-window -t "${session_name}:${window_number}" -c "$dir"
|
||||
fi
|
||||
# minimize window so more panes can fit
|
||||
tmux resize-pane -t "${session_name}:${window_number}" -U "999"
|
||||
tmux resize-pane -t "${session_name}:${window_number}" -U "999"
|
||||
}
|
||||
|
||||
restore_pane() {
|
||||
local pane="$1"
|
||||
while IFS=$d read line_type session_name window_number 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_active window_flags pane_index pane_title dir pane_active pane_command pane_full_command; do
|
||||
dir="$(remove_first_char "$dir")"
|
||||
pane_full_command="$(remove_first_char "$pane_full_command")"
|
||||
if [ "$session_name" == "0" ]; then
|
||||
@ -200,6 +200,8 @@ restore_pane() {
|
||||
else
|
||||
new_session "$session_name" "$window_number" "$dir" "$pane_index"
|
||||
fi
|
||||
# set pane title
|
||||
tmux select-pane -t "$session_name:$window_number.$pane_index" -T "$pane_title"
|
||||
done < <(echo "$pane")
|
||||
}
|
||||
|
||||
@ -323,7 +325,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/ && $10 !~ "^:$" { print $2, $3, $6, $7, $10; }' $(last_resurrect_file) |
|
||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $11 !~ "^:$" { print $2, $3, $6, $8, $11; }' $(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")"
|
||||
@ -333,7 +335,7 @@ restore_all_pane_processes() {
|
||||
}
|
||||
|
||||
restore_active_pane_for_each_window() {
|
||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $8 == 1 { print $2, $3, $6; }' $(last_resurrect_file) |
|
||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $9 == 1 { print $2, $3, $6; }' $(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"
|
||||
@ -341,7 +343,7 @@ restore_active_pane_for_each_window() {
|
||||
}
|
||||
|
||||
restore_zoomed_windows() {
|
||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $5 ~ /Z/ && $8 == 1 { print $2, $3; }' $(last_resurrect_file) |
|
||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $5 ~ /Z/ && $9 == 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
|
||||
|
@ -39,6 +39,8 @@ pane_format() {
|
||||
format+="${delimiter}"
|
||||
format+="#{pane_index}"
|
||||
format+="${delimiter}"
|
||||
format+="#{pane_title}"
|
||||
format+="${delimiter}"
|
||||
format+=":#{pane_current_path}"
|
||||
format+="${delimiter}"
|
||||
format+="#{pane_active}"
|
||||
@ -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_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_active window_flags pane_index pane_title dir pane_active pane_command pane_pid history_size; 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_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_active}${d}${window_flags}${d}${pane_index}${d}${pane_title}${d}${dir}${d}${pane_active}${d}${pane_command}${d}:${full_command}"
|
||||
done
|
||||
}
|
||||
|
||||
@ -259,7 +261,7 @@ dump_state() {
|
||||
dump_pane_contents() {
|
||||
local pane_contents_area="$(get_tmux_option "$pane_contents_area_option" "$default_pane_contents_area")"
|
||||
dump_panes_raw |
|
||||
while IFS=$d read line_type session_name window_number 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_active window_flags pane_index pane_title dir pane_active pane_command pane_pid history_size; do
|
||||
capture_pane_contents "${session_name}:${window_number}.${pane_index}" "$history_size" "$pane_contents_area"
|
||||
done
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user