mirror of
https://github.com/tmux-plugins/tmux-resurrect.git
synced 2024-11-22 04:18:48 +00:00
Preserving layout of zoomed windows across restores
The problem is that tmux list-window shows only the current pane layout if a pane is maximized. This is a bug in tmux. In order to avoid this bug we unzoom the window when saving and zoom in again after saving. This implies that the Z flag is no longer set in list-windows, and so it can't be used when restoring. Instead we use the Z flag of the panes (which still have it) to restore the zoom.
This commit is contained in:
parent
3ba092459a
commit
ad52ade4bf
@ -73,3 +73,10 @@ resurrect_history_file() {
|
|||||||
local pane_id="$1"
|
local pane_id="$1"
|
||||||
echo "$(resurrect_dir)/bash_history-${pane_id}"
|
echo "$(resurrect_dir)/bash_history-${pane_id}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
restore_zoomed_windows() {
|
||||||
|
awk 'BEGIN { FS="\t"; OFS="\t" } /^pane/ && $6 ~ /Z/ && $9 == 1 { print $2, $3; }' $(last_resurrect_file) |
|
||||||
|
while IFS=$'\t' read session_name window_number; do
|
||||||
|
tmux resize-pane -t "${session_name}:${window_number}" -Z
|
||||||
|
done
|
||||||
|
}
|
||||||
|
@ -183,13 +183,6 @@ restore_active_pane_for_each_window() {
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_zoomed_windows() {
|
|
||||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^window/ && $5 ~ /Z/ { print $2, $3; }' $(last_resurrect_file) |
|
|
||||||
while IFS=$'\t' read session_name window_number; do
|
|
||||||
tmux resize-pane -t "${session_name}:${window_number}" -Z
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
restore_active_and_alternate_windows() {
|
restore_active_and_alternate_windows() {
|
||||||
awk 'BEGIN { FS="\t"; OFS="\t" } /^window/ && $5 ~ /[*-]/ { print $2, $4, $3; }' $(last_resurrect_file) |
|
awk 'BEGIN { FS="\t"; OFS="\t" } /^window/ && $5 ~ /[*-]/ { print $2, $4, $3; }' $(last_resurrect_file) |
|
||||||
sort -u |
|
sort -u |
|
||||||
|
@ -100,8 +100,16 @@ save_shell_history() {
|
|||||||
dump_panes() {
|
dump_panes() {
|
||||||
local full_command
|
local full_command
|
||||||
local d=$'\t' # delimiter
|
local d=$'\t' # delimiter
|
||||||
|
local last_resized="none-resized"
|
||||||
dump_panes_raw |
|
dump_panes_raw |
|
||||||
while IFS=$'\t' read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command pane_pid; do
|
while IFS=$'\t' read line_type session_name window_number window_name window_active window_flags pane_index dir pane_active pane_command pane_pid; do
|
||||||
|
# check if current pane is part of a maximized window and if we haven't maximized it already
|
||||||
|
if [[ "${window_flags}" == *Z* ]] && [[ "${last_resized}" != ${window_number} ]]; then
|
||||||
|
# unmaximize the pane
|
||||||
|
tmux resize-pane -Z -t "${session_name}:${window_number}"
|
||||||
|
# set last resized window to current number in order to avoid maximizing again
|
||||||
|
last_resized=${window_number}
|
||||||
|
fi
|
||||||
full_command="$(pane_full_command $pane_pid)"
|
full_command="$(pane_full_command $pane_pid)"
|
||||||
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}${dir}${d}${pane_active}${d}${pane_command}${d}:${full_command}"
|
||||||
done
|
done
|
||||||
@ -132,6 +140,7 @@ save_all() {
|
|||||||
if save_bash_history_option_on; then
|
if save_bash_history_option_on; then
|
||||||
dump_bash_history
|
dump_bash_history
|
||||||
fi
|
fi
|
||||||
|
restore_zoomed_windows
|
||||||
}
|
}
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user