diff --git a/scripts/fingers.sh b/scripts/fingers.sh index bb07d61..e67756a 100755 --- a/scripts/fingers.sh +++ b/scripts/fingers.sh @@ -14,8 +14,9 @@ tmux_yank_copy_command=$(tmux_list_vi_copy_keys | grep -E "(vi-copy|copy-mode-vi current_pane_id=$1 fingers_pane_id=$2 -pane_input_temp=$3 -original_rename_setting=$4 +fingers_window_id=$2 +pane_input_temp=$4 +original_rename_setting=$5 BACKSPACE=$'\177' @@ -41,7 +42,7 @@ function zoom_pane() { function handle_exit() { tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id" [[ $pane_was_zoomed == "1" ]] && zoom_pane "$current_pane_id" - tmux kill-pane -t "$fingers_pane_id" + tmux kill-window -t "$fingers_window_id" tmux set-window-option automatic-rename "$original_rename_setting" rm -rf "$pane_input_temp" "$pane_output_temp" "$match_lookup_table" } @@ -175,7 +176,7 @@ while read -rsn1 char; do copy_result "$result" - revert_to_original_pane "$current_pane_id" "$fingers_pane_id" + revert_to_original_pane "$current_pane_id" "$fingers_pane_id" "$fingers_window_id" exit 0 done < /dev/tty diff --git a/scripts/hints.sh b/scripts/hints.sh index 9fa3659..9ee0ee6 100755 --- a/scripts/hints.sh +++ b/scripts/hints.sh @@ -37,6 +37,6 @@ function show_hints_and_swap() { current_pane_id=$1 fingers_pane_id=$2 compact_state=$3 - show_hints "$fingers_pane_id" $compact_state + show_hints "$fingers_pane_id" "$compact_state" tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id" } diff --git a/scripts/tmux-fingers.sh b/scripts/tmux-fingers.sh index 12e32ca..f3523cb 100755 --- a/scripts/tmux-fingers.sh +++ b/scripts/tmux-fingers.sh @@ -4,8 +4,22 @@ CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" source $CURRENT_DIR/utils.sh function init_fingers_pane() { - local pane_id=$(tmux new-window -F "#{pane_id}" -P -d -n "[fingers]" "$(init_pane_cmd)") - echo $pane_id + local fingers_ids=$(tmux new-window -F "#{pane_id}:#{window_id}" -P -d -n "[fingers]" "$(init_pane_cmd)") + local fingers_pane_id=$(echo "$fingers_ids" | cut -f1 -d:) + local fingers_window_id=$(echo "$fingers_ids" | cut -f2 -d:) + + local current_size=$(tmux list-panes -F "#{pane_width}:#{pane_height}:#{?pane_active,active,nope}" | grep active) + local current_width=$(echo "$current_size" | cut -f1 -d:) + local current_height=$(echo "$current_size" | cut -f2 -d:) + + local current_window_size=$(tmux list-windows -F "#{window_width}:#{window_height}:#{?window_active,active,nope}" | grep active) + local current_window_width=$(echo "$current_window_size" | cut -f1 -d:) + local current_window_height=$(echo "$current_window_size" | cut -f2 -d:) + + tmux split-window -d -t "$fingers_pane_id" -h -l "$(expr "$current_window_width" - "$current_width" - 1)" '/bin/nop' + tmux split-window -d -t "$fingers_pane_id" -l "$(expr "$current_window_height" - "$current_height" - 1)" '/bin/nop' + + echo "$fingers_pane_id:$fingers_window_id" } function capture_pane() { @@ -32,7 +46,9 @@ function capture_pane() { function prompt_fingers_for_pane() { local current_pane_id=$1 - local fingers_pane_id=$(init_fingers_pane) + local fingers_init_data=$(init_fingers_pane) + local fingers_pane_id=$(echo "$fingers_init_data" | cut -f1 -d':') + local fingers_window_id=$(echo "$fingers_init_data" | cut -f2 -d':') local tmp_path=$(fingers_tmp) wait @@ -41,7 +57,7 @@ function prompt_fingers_for_pane() { local original_rename_setting=$(tmux show-window-option -gv automatic-rename) 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\" $tmp_path $original_rename_setting" + 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" echo $fingers_pane_id } diff --git a/scripts/utils.sh b/scripts/utils.sh index eec7f1e..4731030 100755 --- a/scripts/utils.sh +++ b/scripts/utils.sh @@ -69,8 +69,9 @@ function display_message() { function revert_to_original_pane() { local current_pane_id=$1 local fingers_pane_id=$2 + local fingers_window_id=$3 tmux swap-pane -s "$current_pane_id" -t "$fingers_pane_id" - tmux kill-pane -t "$fingers_pane_id" + tmux kill-window -t "$fingers_window_id" } function pane_exec() {