]> Sergey Matveev's repositories - dotfiles.git/blob - bin/bin/pe
fzf
[dotfiles.git] / bin / bin / pe
1 #!/bin/zsh
2
3 exec >&2
4 fns=()
5 toprint=()
6 typeset -A seen
7 ctr=0
8 path-extractor | while read fn ; do
9     [[ $seen[$fn] -eq 1 ]] && continue
10     seen+=($fn 1)
11     fns+=($fn)
12     toprint+=(`printf "%X:%s" $ctr "${fn}"`)
13     ctr=$(( $ctr + 1 ))
14 done
15 [[ $ctr -le 20 ]] && print -C 1 $toprint || print -c $toprint
16 print -n "> "
17 read choice < /dev/tty
18 [[ "$choice" = "q" ]] && exit
19 if [[ "$choice" = "*" ]]; then
20     buf=$fns
21 else
22     buf=()
23     for c in ${=choice} ; do
24         fn=$fns[$(( 1 + 16#$c ))]
25         buf+=($fn)
26     done
27 fi
28 print $buf
29 print -n $buf | xclip -in -selection clipboard