This commit is contained in:
Ferran Basora 2017-04-18 15:04:34 +00:00 committed by GitHub
commit 27355e7384
2 changed files with 8 additions and 83 deletions

View File

@ -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 "Space"
else
tmux send-keys "C-Space"
fi
}
function top_of_buffer() {
if [ "$TMUX_COPY_MODE" == "vi" ]; then
tmux send-keys "H"
else
tmux send-keys "M-R"
fi
}
function start_of_line() {
if [ "$TMUX_COPY_MODE" == "vi" ]; then
tmux send-keys "0"
else
tmux send-keys "C-a"
fi
}
function end_of_line() {
if [ "$TMUX_COPY_MODE" == "vi" ]; then
tmux send-keys "$"
else
tmux send-keys "C-e"
fi
}
function cursor_left() {
if [ "$TMUX_COPY_MODE" == "vi" ]; then
tmux send-keys "h"
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 "Enter"
else
tmux send-keys "M-w"
fi
}

View File

@ -3,7 +3,6 @@
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $CURRENT_DIR/config.sh
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,19 @@ 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!"
tmux set-buffer "$result"
if [ ! -z "$FINGERS_COPY_COMMAND" ]; then
echo -n "$result" | eval "nohup $FINGERS_COPY_COMMAND" > /dev/null
fi
revert_to_original_pane "$current_pane_id" "$fingers_pane_id"
exit 0