From 1bfce57aaa7ffca6657a0f4ed645bc1ba54bf081 Mon Sep 17 00:00:00 2001 From: Gregory Pakosz Date: Mon, 7 Nov 2016 22:34:31 +0100 Subject: [PATCH] fixed maximize pane when another session already contains a maximized window, fixes #37 --- .tmux.conf | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.tmux.conf b/.tmux.conf index b2748e8..52e3dad 100644 --- a/.tmux.conf +++ b/.tmux.conf @@ -171,17 +171,18 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # } # # _maximize_pane() { -# current_pane=$(tmux display -p '#{pane_id}') +# current_session=${1:-$(tmux display -p '#{session_name}')} +# current_pane=${2:-$(tmux display -p '#{pane_id}')} # -# dead_panes=$(tmux list-panes -s -F '#{pane_dead} #{pane_id} #{pane_start_command}' | grep -o '^1 %.\+maximized.\+$' || true) +# dead_panes=$(tmux list-panes -s -t "$current_session" -F '#{pane_dead} #{pane_id} #{pane_start_command}' | grep -o '^1 %.\+maximized.\+$' || true) # restore=$(echo "$dead_panes" | sed -n -E -e "s/^1 $current_pane .+maximized.+(%[0-9]+)$/tmux swap-pane -s \1 -t $current_pane \; kill-pane -t $current_pane/p" -e "s/^1 (%[0-9]+) .+maximized.+$current_pane$/tmux swap-pane -s \1 -t $current_pane \; kill-pane -t \1/p" ) # # if [ -z "$restore" ]; then -# [ "$(tmux list-panes | wc -l | sed 's/^ *//g')" -eq 1 ] && tmux display "Can't maximize with only one pane" && return -# window=$(tmux new-window -P "exec maximized... 2> /dev/null & tmux setw remain-on-exit on; printf 'Pane has been maximized, press + to restore. %s' \\$current_pane") +# [ "$(tmux list-panes -t "$current_session:" | wc -l | sed 's/^ *//g')" -eq 1 ] && tmux display "Can't maximize with only one pane" && return +# window=$(tmux new-window -t "$current_session:" -P "exec maximized... 2> /dev/null & tmux setw -t $current_session remain-on-exit on; printf 'Pane has been maximized, press + to restore. %s' \\$current_pane") # window=${window%.*} # -# guard=50 +# guard=10 # while [ x"$(tmux list-panes -t "$window" -F '#{session_name}:#{window_index} #{pane_dead}' 2>/dev/null)" != x"$window 1" ] && [ "$guard" -ne 0 ]; do # sleep 0.01 # guard=$((guard - 1)) @@ -191,7 +192,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # fi # # new_pane=$(tmux display -p '#{pane_id}') -# tmux setw remain-on-exit off \; swap-pane -s "$current_pane" -t "$new_pane" +# tmux setw -t "$window" remain-on-exit off \; swap-pane -s "$current_pane" -t "$new_pane" # else # $restore || tmux kill-pane # fi @@ -613,7 +614,7 @@ run 'cut -c3- ~/.tmux.conf | sh -s _apply_configuration' # fi # # if tmux -q -L swap-pane-test -f /dev/null new-session -d \; new-window \; new-window \; swap-pane -t :1 \; kill-session; then -# tmux bind + run 'cut -c3- ~/.tmux.conf | sh -s _maximize_pane' +# tmux bind + run 'cut -c3- ~/.tmux.conf | sh -s _maximize_pane #{session_name} #D' # else # tmux bind + display 'your tmux version has a buggy swap-pane command - see ticket #108, fixed in upstream commit 78e783e' # fi