]> Sergey Matveev's repositories - dotfiles.git/blobdiff - bin/bin/path-extractor.zsh
path-extractor popup
[dotfiles.git] / bin / bin / path-extractor.zsh
diff --git a/bin/bin/path-extractor.zsh b/bin/bin/path-extractor.zsh
new file mode 100755 (executable)
index 0000000..2a93173
--- /dev/null
@@ -0,0 +1,28 @@
+#!/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
+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