]> Sergey Matveev's repositories - dotfiles.git/commitdiff
More fzf/path-extractor convenience
authorSergey Matveev <stargrave@stargrave.org>
Wed, 3 Feb 2021 14:35:44 +0000 (17:35 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 3 Feb 2021 15:11:10 +0000 (18:11 +0300)
bin/bin/pe
bin/bin/tmux-path-extractor.sh
tmux/.tmux.conf
zsh/.zshenv
zsh/.zshrc

index 8b64702a77f53de9de5150d9b83fc684eafd66dd..77c87900af33164db4a2c53cefe4ba53432c3bcd 100755 (executable)
@@ -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"
index 4375c598b2d149687cf9f53fdaa40032f99dda98..162f0bb0353c270c20f41fc1e3e651c825957d00 100755 (executable)
@@ -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
index d25d9c7b510285aa63b0fa2bf79ba49f83f1194e..1d414d311af0564ff6d18b5d17ba8b8a7d961101 100644 (file)
@@ -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 {
index d455788807b9d4893b3d210afc337bd68325ccae..9bb060525f80c7d90704d48d332be877c639663e 100644 (file)
@@ -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"
 # }}}
index e5f02abe87c2c2666e9ab84a04dc6b6b09c38874..b1baea7bc1d29331c45195ce068a9f89d1cb6ce0 100644 (file)
@@ -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
 # }}}