From 0fd04a96478a8bb4b95a95e9ada86c6aac4b3867 Mon Sep 17 00:00:00 2001 From: Ferran Basora Date: Tue, 11 Apr 2017 10:06:57 +0000 Subject: [PATCH] Remove actions --- scripts/actions.sh | 60 ---------------------------------------------- scripts/fingers.sh | 32 +++++++------------------ 2 files changed, 9 insertions(+), 83 deletions(-) delete mode 100755 scripts/actions.sh diff --git a/scripts/actions.sh b/scripts/actions.sh deleted file mode 100755 index 46a35f8..0000000 --- a/scripts/actions.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env bash - -CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -TMUX_COPY_MODE=$(tmux show-option -gwv mode-keys) -HAS_TMUX_YANK=$([ "$(tmux list-keys | grep -c tmux-yank)" == "0" ]; echo $?) - -function start_copy_mode() { - tmux copy-mode -} - -function start_selection() { - if [ "$TMUX_COPY_MODE" == "vi" ]; then - tmux send-keys -X begin-selection - else - tmux send-keys "C-Space" - fi -} - -function top_of_buffer() { - if [ "$TMUX_COPY_MODE" == "vi" ]; then - tmux send-keys -X top-line - else - tmux send-keys "M-R" - fi -} - -function start_of_line() { - if [ "$TMUX_COPY_MODE" == "vi" ]; then - tmux send-keys -X start-of-line - else - tmux send-keys "C-a" - fi -} - -function end_of_line() { - if [ "$TMUX_COPY_MODE" == "vi" ]; then - tmux send-keys -X end-of-line - else - tmux send-keys "C-e" - fi -} - -function cursor_left() { - if [ "$TMUX_COPY_MODE" == "vi" ]; then - tmux send-keys -X cursor-left - fi -} - -function copy_selection() { - if [ "$HAS_TMUX_YANK" == "1" ]; then - tmux send-keys "y" - return - fi - - if [ "$TMUX_COPY_MODE" == "vi" ]; then - tmux send-keys -X copy-selection-and-cancel - else - tmux send-keys "M-w" - fi -} diff --git a/scripts/fingers.sh b/scripts/fingers.sh index 8491c6e..23c7d38 100755 --- a/scripts/fingers.sh +++ b/scripts/fingers.sh @@ -5,7 +5,6 @@ eval "$(tmux show-env -s | grep ^FINGERS)" CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -source $CURRENT_DIR/actions.sh source $CURRENT_DIR/hints.sh source $CURRENT_DIR/utils.sh source $CURRENT_DIR/help.sh @@ -39,24 +38,6 @@ function handle_exit() { rm -rf "$pane_input_temp" "$pane_output_temp" "$match_lookup_table" } -function copy_result() { - local result=$1 - - clear - echo -n "$result" - start_copy_mode - top_of_buffer - start_of_line - start_selection - end_of_line - cursor_left - copy_selection - - if [ ! -z "$FINGERS_COPY_COMMAND" ]; then - echo -n "$result" | eval "nohup $FINGERS_COPY_COMMAND" > /dev/null - fi -} - function is_valid_input() { local input=$1 local is_valid=1 @@ -152,15 +133,20 @@ while read -rsn1 char; do show_hints "$fingers_pane_id" $compact_state fi - result=$(lookup_match "$input") - - tmux display-message "$input" + result=$(lookup_match "$input" | head -n 1) if [[ -z $result ]]; then continue fi - copy_result "$result" + tmux display-message "'$result' copied!" + + if [ ! -z "$FINGERS_COPY_COMMAND" ]; then + echo -n "$result" | eval "nohup $FINGERS_COPY_COMMAND" > /dev/null + else + tmux set-buffer "$result" + fi + revert_to_original_pane "$current_pane_id" "$fingers_pane_id" exit 0