diff --git a/scripts/fingers.sh b/scripts/fingers.sh index 23c7d38..ee3ec78 100755 --- a/scripts/fingers.sh +++ b/scripts/fingers.sh @@ -90,6 +90,16 @@ function toggle_help() { fi } +function copy_result() { + local result="$1" + + tmux set-buffer "$result" + + if [ ! -z "$FINGERS_COPY_COMMAND" ]; then + echo -n "$result" | eval "nohup $FINGERS_COPY_COMMAND" > /dev/null + fi +} + while read -rsn1 char; do # Escape sequence, flush input if [[ "$char" == $'\x1b' ]]; then @@ -133,19 +143,13 @@ while read -rsn1 char; do show_hints "$fingers_pane_id" $compact_state fi - result=$(lookup_match "$input" | head -n 1) + result=$(lookup_match "$input") if [[ -z $result ]]; then continue fi - 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 + copy_result "$result" revert_to_original_pane "$current_pane_id" "$fingers_pane_id" diff --git a/scripts/hints.sh b/scripts/hints.sh index 2182aa6..104ecae 100755 --- a/scripts/hints.sh +++ b/scripts/hints.sh @@ -13,7 +13,7 @@ export pane_output_temp function lookup_match() { local input=$1 - echo "$(cat $match_lookup_table | grep "^$input:" | sed "s/^$input://")" + echo "$(cat $match_lookup_table | grep "^$input:" | sed "s/^$input://" | head -n 1)" } function get_stdin() {