diff options
Diffstat (limited to '.local/bin/file-search')
-rwxr-xr-x | .local/bin/file-search | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/.local/bin/file-search b/.local/bin/file-search new file mode 100755 index 0000000..130b90c --- /dev/null +++ b/.local/bin/file-search @@ -0,0 +1,28 @@ +#!/bin/sh -eu + +cache=/tmp/file_search_results.cache +append() { find "$1" -maxdepth 1 -printf "%p\n" 2> /dev/null || true; } +appendRecursive() { find "$1" -printf "%p\n" 2>/dev/null || true; } +removeDuplicates() { awk '!visited[$0]++' "$1" | sponge "$1"; } + +{ [ ! -f "$cache" ] || [ "${1:-}" = "update" ]; } && \ + { + append "$HOME"; + append "$HOME"/.local; + append "$HOME"/Desktop; + append "$HOME"/Shares/Projects; + appendRecursive "$HOME"/.vim; + appendRecursive "$HOME"/.local/bin; + appendRecursive "$HOME"/.config; + appendRecursive "$HOME"/Music; + appendRecursive "$HOME"/Books; + appendRecursive "$HOME"/Videos; + appendRecursive "$HOME"/Documents; + appendRecursive "$HOME"/Downloads; + appendRecursive "$HOME"/Pictures; + } \ + | grep -vE '(undodir)' > "$cache" + +[ "${1:-}" = "update" ] && removeDuplicates "$cache" && exit; + +xdg-open "$(rofi -font "ubuntu 12" -matching regex -padding 20 -dmenu -i -p 'Files' < "$cache")" |