From 819d5b63962cb016bcb5b0bc58bf8bdc00aa147d Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Wed, 3 Feb 2021 17:35:44 +0300 Subject: [PATCH] More fzf/path-extractor convenience --- bin/bin/pe | 26 +++----------------------- bin/bin/tmux-path-extractor.sh | 6 +----- tmux/.tmux.conf | 2 ++ zsh/.zshenv | 2 -- zsh/.zshrc | 12 ++++++++++++ 5 files changed, 18 insertions(+), 30 deletions(-) diff --git a/bin/bin/pe b/bin/bin/pe index 8b64702..77c8790 100755 --- a/bin/bin/pe +++ b/bin/bin/pe @@ -1,29 +1,9 @@ #!/bin/zsh -exec >&2 -fns=() -toprint=() typeset -A seen -ctr=0 path-extractor | while read fn ; do [[ $seen[$fn] -eq 1 ]] && continue seen+=($fn 1) - fns+=($fn) - toprint+=(`printf "%X:%s" $ctr "${fn}"`) - ctr=$(( $ctr + 1 )) -done -[[ $ctr -le 20 ]] && print -C 1 $toprint || print -c $toprint -print -n "> " -read choice < /dev/tty -[[ "$choice" = "q" ]] && exit -if [[ "$choice" = "*" ]]; then - buf=$fns -else - buf=() - for c in ${=choice} ; do - fn=$fns[$(( 1 + 16#$c ))] - buf+=($fn) - done -fi -print $buf -print -n $buf | xclip -in -selection clipboard + print $fn +done | fzf -m | tr "\n" " " | read data +tmux set-buffer "$data" diff --git a/bin/bin/tmux-path-extractor.sh b/bin/bin/tmux-path-extractor.sh index 4375c59..162f0bb 100755 --- a/bin/bin/tmux-path-extractor.sh +++ b/bin/bin/tmux-path-extractor.sh @@ -1,10 +1,6 @@ #!/bin/sh tmux has-session -t path-extractor && tmux kill-session -t path-extractor || : -tmux new-session -d -s path-extractor " - ~/bin/pe < /tmp/tmux-buffer - tmux detach - sleep 20 -" +tmux new-session -d -s path-extractor "pe < /tmp/tmux-buffer ; tmux detach" tmux set-option -t path-extractor status off exec tmux attach-session -t path-extractor diff --git a/tmux/.tmux.conf b/tmux/.tmux.conf index d25d9c7..1d414d3 100644 --- a/tmux/.tmux.conf +++ b/tmux/.tmux.conf @@ -61,6 +61,8 @@ bind-key o { save-buffer /tmp/tmux-buffer delete-buffer display-popup -KE -w 100% -R "~/bin/tmux-path-extractor.sh" + paste-buffer + delete-buffer } bind-key Y { diff --git a/zsh/.zshenv b/zsh/.zshenv index d455788..9bb0605 100644 --- a/zsh/.zshenv +++ b/zsh/.zshenv @@ -93,6 +93,4 @@ export DBUS_SESSION_BUS_ADDRESS=disabled: export MYSQL_HISTFILE=/tmp/.mysql_history export REDO_JOBS=0 REDO_NO_SYNC=1 export SHARNESS_TEST_SRCDIR=$HOME/local/stow/sharness/share/sharness -export FZF_CTRL_T_COMMAND="print -C 1 **~.git/*" -export FZF_DEFAULT_OPTS="--inline-info" # }}} diff --git a/zsh/.zshrc b/zsh/.zshrc index e5f02ab..b1baea7 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -210,5 +210,17 @@ ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=cyan" # }}} # fzf {{{ +alias -g PE="| pe" + +export FZF_DEFAULT_OPTS="--color=16 --info=inline --preview='less -N -S {}'" + +_fzf_find() { + find . \( -path "*/\.git" -o -fstype devfs -o -fstype procfs \) -prune \ + -o -type d -print $@ 2>/dev/null | cut -b3- +} + +export FZF_CTRL_T_COMMAND="_fzf_find -o -type f -print -o -type l -print" +export FZF_ALT_C_COMMAND=_fzf_find + . ~/work/fzf/shell/key-bindings.zsh # }}} -- 2.44.0