remove tmux-yank dependency and provide default copy/open command
This commit is contained in:
parent
bf24ffc2af
commit
1b3871250e
|
@ -25,10 +25,6 @@ Here is a list of the stuff highlighted by default.
|
||||||
It also works on copy mode, but requires *tmux 2.2* or newer to properly take
|
It also works on copy mode, but requires *tmux 2.2* or newer to properly take
|
||||||
the scroll position into account.
|
the scroll position into account.
|
||||||
|
|
||||||
Additionally, you can install
|
|
||||||
[tmux-yank](https://github.com/tmux-plugins/tmux-yank) for system clipboard
|
|
||||||
integration.
|
|
||||||
|
|
||||||
## Key shortcuts
|
## Key shortcuts
|
||||||
|
|
||||||
While in **[fingers]** mode, you can use the following shortcuts:
|
While in **[fingers]** mode, you can use the following shortcuts:
|
||||||
|
|
|
@ -51,12 +51,8 @@ git submodule update --init --recursive"
|
||||||
tmux source ~/.tmux.conf"
|
tmux source ~/.tmux.conf"
|
||||||
```
|
```
|
||||||
|
|
||||||
## reattach-to-user-namespace is recommended
|
## system clipboard integration
|
||||||
|
|
||||||
If you are using tmux 2.5 or less and OSX, it's recommended that you install `reattach-to-user-namespace` in for system clipboard integration.
|
In order for system clipboard integration to work, you need to have program in your system that manages that.
|
||||||
|
|
||||||
```
|
Check [tmux-yank documentation](https://github.com/tmux-plugins/tmux-yank#requirements) to check what program do you need to install, depending on your platform.
|
||||||
brew install reattach-to-user-namespace
|
|
||||||
```
|
|
||||||
|
|
||||||
Remember that you need to install [tmux-yank](https://github.com/tmux-plugins/tmux-yank) as well.
|
|
||||||
|
|
|
@ -50,6 +50,37 @@ function strip_format () {
|
||||||
echo "$1" | sed "s/#\[[^]]*\]//g"
|
echo "$1" | sed "s/#\[[^]]*\]//g"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function default_copy_command () {
|
||||||
|
# installing reattach-to-user-namespace is recommended on OS X
|
||||||
|
if [[ $(program_exists "pbcopy") = "1" ]]; then
|
||||||
|
if [[ $(program_exists "reattach-to-user-namespace") = "1" ]]; then
|
||||||
|
echo "reattach-to-user-namespace pbcopy"
|
||||||
|
else
|
||||||
|
echo "pbcopy"
|
||||||
|
fi
|
||||||
|
elif [[ $(program_exists "clip.exe") = "1" ]]; then # WSL clipboard command
|
||||||
|
echo "cat | clip.exe"
|
||||||
|
elif [[ $(program_exists "wl-copy") = "1" ]]; then # wl-clipboard: Wayland clipboard utilities
|
||||||
|
echo "wl-copy"
|
||||||
|
elif [[ $(program_exists "xsel") = "1" ]]; then
|
||||||
|
echo "xsel -i --clipboard"
|
||||||
|
elif [[ $(program_exists "xclip") = "1" ]]; then
|
||||||
|
echo "xclip -selection clipboard"
|
||||||
|
elif [[ $(program_exists "putclip") = "1" ]]; then # cygwin clipboard command
|
||||||
|
echo "putclip"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function default_open_command () {
|
||||||
|
if [[ $(program_exists "open") = "1" ]]; then
|
||||||
|
echo "xargs open"
|
||||||
|
elif [[ $(program_exists "xdg-open") = "1" ]]; then
|
||||||
|
echo "xargs xdg-open"
|
||||||
|
elif [[ $(program_exists "cygstart") = "1" ]]; then
|
||||||
|
echo "xargs cygstart"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
PATTERNS_LIST=(
|
PATTERNS_LIST=(
|
||||||
"((^|^\.|[[:space:]]|[[:space:]]\.|[[:space:]]\.\.|^\.\.)[[:alnum:]~_-]*/[][[:alnum:]_.#$%&+=/@-]+)"
|
"((^|^\.|[[:space:]]|[[:space:]]\.|[[:space:]]\.\.|^\.\.)[[:alnum:]~_-]*/[][[:alnum:]_.#$%&+=/@-]+)"
|
||||||
"([[:digit:]]{4,})"
|
"([[:digit:]]{4,})"
|
||||||
|
@ -84,8 +115,8 @@ PATTERNS=$(array_join "|" "${PATTERNS_LIST[@]}")
|
||||||
fingers_defaults=( \
|
fingers_defaults=( \
|
||||||
[fingers-patterns]="$PATTERNS" \
|
[fingers-patterns]="$PATTERNS" \
|
||||||
[fingers-compact-hints]=1 \
|
[fingers-compact-hints]=1 \
|
||||||
[fingers-copy-command]="" \
|
[fingers-copy-command]="$(default_copy_command)" \
|
||||||
[fingers-copy-command-uppercase]="" \
|
[fingers-copy-command-uppercase]="$(default_open_command)" \
|
||||||
|
|
||||||
[fingers-hint-position]="left" \
|
[fingers-hint-position]="left" \
|
||||||
[fingers-hint-format]="#[fg=yellow,bold]%s" \
|
[fingers-hint-format]="#[fg=yellow,bold]%s" \
|
||||||
|
|
|
@ -8,9 +8,6 @@ source $CURRENT_DIR/hints.sh
|
||||||
source $CURRENT_DIR/utils.sh
|
source $CURRENT_DIR/utils.sh
|
||||||
source $CURRENT_DIR/help.sh
|
source $CURRENT_DIR/help.sh
|
||||||
|
|
||||||
HAS_TMUX_YANK=$([ "$(tmux list-keys | grep -c tmux-yank)" == "0" ]; echo $?)
|
|
||||||
tmux_yank_copy_command=$(tmux_list_vi_copy_keys | grep -E "(vi-copy|copy-mode-vi) *y" | sed -E 's/.*copy-pipe(-and-cancel)? *(.*)/\2/g')
|
|
||||||
|
|
||||||
current_pane_id=$1
|
current_pane_id=$1
|
||||||
fingers_pane_id=$2
|
fingers_pane_id=$2
|
||||||
last_pane_id=$3
|
last_pane_id=$3
|
||||||
|
@ -130,10 +127,6 @@ function copy_result() {
|
||||||
local hint="$2"
|
local hint="$2"
|
||||||
|
|
||||||
tmux set-buffer "$result"
|
tmux set-buffer "$result"
|
||||||
|
|
||||||
if [[ $HAS_TMUX_YANK = 1 ]]; then
|
|
||||||
tmux run-shell -b "printf \"$result\" | $EXEC_PREFIX $(echo "$tmux_yank_copy_command")"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function run_fingers_copy_command() {
|
function run_fingers_copy_command() {
|
||||||
|
|
|
@ -31,17 +31,6 @@ function version_minor() {
|
||||||
echo "$1" | cut -f2 -d. | grep -Eo "[0-9]"
|
echo "$1" | cut -f2 -d. | grep -Eo "[0-9]"
|
||||||
}
|
}
|
||||||
|
|
||||||
function program_exists() {
|
|
||||||
local prog="$1"
|
|
||||||
|
|
||||||
which "$prog" &> /dev/null
|
|
||||||
|
|
||||||
if [[ $? == "0" ]]; then
|
|
||||||
echo "1"
|
|
||||||
else
|
|
||||||
echo "0"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function log_message() {
|
function log_message() {
|
||||||
log_messages+=("$1")
|
log_messages+=("$1")
|
||||||
|
|
|
@ -146,3 +146,15 @@ function resolve_path() {
|
||||||
echo "$(readlink -f "$path")"
|
echo "$(readlink -f "$path")"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function program_exists() {
|
||||||
|
local prog="$1"
|
||||||
|
|
||||||
|
which "$prog" &> /dev/null
|
||||||
|
|
||||||
|
if [[ $? == "0" ]]; then
|
||||||
|
echo "1"
|
||||||
|
else
|
||||||
|
echo "0"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
set -g prefix C-a
|
|
||||||
set -g @fingers-compact-hints '0'
|
|
||||||
bind-key -T copy-mode-vi y send-keys -X copy-pipe-and-cancel "bash /home/vagrant/shared/test/stubs/tmux-yank.sh"
|
|
||||||
|
|
||||||
run /home/vagrant/shared/tmux-fingers.tmux
|
|
|
@ -1,20 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
CURRENT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
|
||||||
source $CURRENT_DIR/../tmuxomatic.sh
|
|
||||||
source $CURRENT_DIR/../helpers.sh
|
|
||||||
|
|
||||||
tmuxomatic__begin begin_hook
|
|
||||||
|
|
||||||
begin_with_conf "tmux-yank"
|
|
||||||
init_pane
|
|
||||||
|
|
||||||
tmuxomatic__exec "cat ./test/fixtures/grep-output"
|
|
||||||
invoke_fingers
|
|
||||||
tmuxomatic send-keys "d"
|
|
||||||
|
|
||||||
tmuxomatic__sleep 1
|
|
||||||
tmuxomatic__exec "cat /tmp/tmux-yank-result"
|
|
||||||
|
|
||||||
tmuxomatic__expect "tmux-yank yolo"
|
|
||||||
tmuxomatic__end end_hook
|
|
|
@ -1,3 +0,0 @@
|
||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
echo "tmux-yank yolo" > /tmp/tmux-yank-result
|
|
Loading…
Reference in New Issue