don't break tmux last-pane ( fixes #48 )
This commit is contained in:
parent
c665f68caa
commit
993cc3dce3
|
@ -13,9 +13,10 @@ tmux_yank_copy_command=$(tmux_list_vi_copy_keys | grep -E "(vi-copy|copy-mode-vi
|
||||||
|
|
||||||
current_pane_id=$1
|
current_pane_id=$1
|
||||||
fingers_pane_id=$2
|
fingers_pane_id=$2
|
||||||
fingers_window_id=$2
|
last_pane_id=$3
|
||||||
pane_input_temp=$4
|
fingers_window_id=$4
|
||||||
original_rename_setting=$5
|
pane_input_temp=$5
|
||||||
|
original_rename_setting=$6
|
||||||
|
|
||||||
BACKSPACE=$'\177'
|
BACKSPACE=$'\177'
|
||||||
|
|
||||||
|
@ -38,11 +39,20 @@ function zoom_pane() {
|
||||||
tmux resize-pane -Z -t "$pane_id"
|
tmux resize-pane -Z -t "$pane_id"
|
||||||
}
|
}
|
||||||
|
|
||||||
function handle_exit() {
|
function revert_to_original_pane() {
|
||||||
tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id"
|
tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id"
|
||||||
[[ $pane_was_zoomed == "1" ]] && zoom_pane "$current_pane_id"
|
|
||||||
tmux kill-window -t "$fingers_window_id"
|
tmux kill-window -t "$fingers_window_id"
|
||||||
|
[[ $pane_was_zoomed == "1" ]] && zoom_pane "$current_pane_id"
|
||||||
tmux set-window-option automatic-rename "$original_rename_setting"
|
tmux set-window-option automatic-rename "$original_rename_setting"
|
||||||
|
|
||||||
|
if [[ ! -z "$last_pane_id" ]]; then
|
||||||
|
tmux select-pane -t "$last_pane_id"
|
||||||
|
tmux select-pane -t "$current_pane_id"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function handle_exit() {
|
||||||
|
revert_to_original_pane
|
||||||
rm -rf "$pane_input_temp" "$pane_output_temp" "$match_lookup_table"
|
rm -rf "$pane_input_temp" "$pane_output_temp" "$match_lookup_table"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +190,7 @@ while read -rsn1 char; do
|
||||||
|
|
||||||
copy_result "$result" "$input"
|
copy_result "$result" "$input"
|
||||||
|
|
||||||
revert_to_original_pane "$current_pane_id" "$fingers_pane_id" "$fingers_window_id"
|
revert_to_original_pane
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
done < /dev/tty
|
done < /dev/tty
|
||||||
|
|
|
@ -46,6 +46,7 @@ function capture_pane() {
|
||||||
|
|
||||||
function prompt_fingers_for_pane() {
|
function prompt_fingers_for_pane() {
|
||||||
local current_pane_id=$1
|
local current_pane_id=$1
|
||||||
|
local last_pane_id=$2
|
||||||
local fingers_init_data=$(init_fingers_pane)
|
local fingers_init_data=$(init_fingers_pane)
|
||||||
local fingers_pane_id=$(echo "$fingers_init_data" | cut -f1 -d':')
|
local fingers_pane_id=$(echo "$fingers_init_data" | cut -f1 -d':')
|
||||||
local fingers_window_id=$(echo "$fingers_init_data" | cut -f2 -d':')
|
local fingers_window_id=$(echo "$fingers_init_data" | cut -f2 -d':')
|
||||||
|
@ -57,10 +58,11 @@ function prompt_fingers_for_pane() {
|
||||||
|
|
||||||
local original_rename_setting=$(tmux show-window-option -gv automatic-rename)
|
local original_rename_setting=$(tmux show-window-option -gv automatic-rename)
|
||||||
tmux set-window-option automatic-rename off
|
tmux set-window-option automatic-rename off
|
||||||
pane_exec "$fingers_pane_id" "cat $tmp_path | $CURRENT_DIR/fingers.sh \"$current_pane_id\" \"$fingers_pane_id\" \"$fingers_window_id\" $tmp_path $original_rename_setting"
|
pane_exec "$fingers_pane_id" "cat $tmp_path | $CURRENT_DIR/fingers.sh \"$current_pane_id\" \"$fingers_pane_id\" \"$last_pane_id\" \"$fingers_window_id\" $tmp_path $original_rename_setting"
|
||||||
|
|
||||||
echo $fingers_pane_id
|
echo $fingers_pane_id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
last_pane_id=$(tmux display -pt':.{last}' '#{pane_id}' 2>/dev/null)
|
||||||
current_pane_id=$(tmux list-panes -F "#{pane_id}:#{?pane_active,active,nope}" | grep active | cut -d: -f1)
|
current_pane_id=$(tmux list-panes -F "#{pane_id}:#{?pane_active,active,nope}" | grep active | cut -d: -f1)
|
||||||
fingers_pane_id=$(prompt_fingers_for_pane $current_pane_id)
|
fingers_pane_id=$(prompt_fingers_for_pane "$current_pane_id" "$last_pane_id")
|
||||||
|
|
|
@ -70,8 +70,16 @@ function revert_to_original_pane() {
|
||||||
local current_pane_id=$1
|
local current_pane_id=$1
|
||||||
local fingers_pane_id=$2
|
local fingers_pane_id=$2
|
||||||
local fingers_window_id=$3
|
local fingers_window_id=$3
|
||||||
|
local last_pane_id=$4
|
||||||
|
local pane_was_zoomed=$5
|
||||||
tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id"
|
tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id"
|
||||||
tmux kill-window -t "$fingers_window_id"
|
tmux kill-window -t "$fingers_window_id"
|
||||||
|
[[ $pane_was_zoomed == "1" ]] && zoom_pane "$current_pane_id"
|
||||||
|
|
||||||
|
if [[ ! -z "$last_pane_id" ]]; then
|
||||||
|
tmux select-pane -t "$last_pane_id"
|
||||||
|
tmux select-pane -t "$current_pane_id"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function pane_exec() {
|
function pane_exec() {
|
||||||
|
|
Loading…
Reference in New Issue