-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfinder.sh
More file actions
executable file
·37 lines (36 loc) · 1.26 KB
/
finder.sh
File metadata and controls
executable file
·37 lines (36 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env bash
#PUT THIS FILE IN ~/.local/share/rofi/finder.sh
#USE: rofi -show find -modi find:~/.local/share/rofi/finder.sh
#TODO: fix doesn't work
if [ ! -z "$@" ]; then
QUERY=$@
if [[ "$@" == /* ]]; then
if [[ "$@" == *\?\? ]]; then
coproc (exo-open "${QUERY%\/* \?\?}" >/dev/null 2>&1)
exec 1>&-
exit
else
coproc (exo-open "$@" >/dev/null 2>&1)
exec 1>&-
exit
fi
elif [[ "$@" == \!\!* ]]; then
echo "!!-- Type your search query to find files"
echo "!!-- To search again type !<search_query>"
echo "!!-- To search parent directories type ?<search_query>"
echo "!!-- You can print this help by typing !!"
elif [[ "$@" == \?* ]]; then
echo "!!-- Type another search query"
while read -r line; do
echo "$line" \?\?
done <<<$(find ~ -type d -path '*/\.*' -prune -o -not -name '.*' -type f -iname *"${QUERY#\?}"* -print)
else
echo "!!-- Type another search query"
find ~ -type d -path '*/\.*' -prune -o -not -name '.*' -type f -iname *"${QUERY#!}"* -print
fi
else
echo "!!-- Type your search query to find files"
echo "!!-- To seach again type !<search_query>"
echo "!!-- To seach parent directories type ?<search_query>"
echo "!!-- You can print this help by typing !!"
fi