dugrep (735B)
1 #!/bin/sh 2 3 # Configuration 4 #theme="-theme sidebar" 5 selector="rofi -width 75% -dmenu -i $theme -p :" 6 7 usage() { 8 echo "dugrep -- finds all files with the .\$1 extention" 9 echo " lets you choose one, then exec with \$2." 10 echo 11 echo "USAGE" 12 echo "\tdugrep EXT EXE [-]" 13 echo 14 echo "\tUse \"-\" to open EXE in a new terminal." 15 exit 1 16 } 17 18 [ -z "$1" ] || [ -z "$2" ] || [ "$1" = "-h" ] \ 19 && usage 20 21 22 filter_files() { 23 for ext in $(echo "$1" | tr "," "\n"); do 24 du -a $HOME --exclude=".*" | cut -f2 | grep "\.$ext$" 25 done 26 } 27 28 file=$(filter_files "$1" | sort | $selector) 29 [ -z "$file" ] && exit 30 31 [ "$3" = "-" ] \ 32 && $TERMINAL -e "$2 \"$file\"" && exit 33 34 $2 "$file" 35 36 #xargs -r -d "\n" "$2" 37