Created
July 4, 2017 09:54
-
-
Save anonymous/2dd555b3e98a78bcba42fa98210c8c1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
findinhome() { | |
find ~/* -iname \*"$1"\*; | |
} | |
case $1 in | |
m) LISTGEN="mpc search any"; | |
HANDLER="mpc insert"; | |
;; | |
f) LISTGEN="findinhome"; | |
HANDLER="exo-open"; | |
;; | |
esac | |
until [[ $QUERY_RESULT != "" ]]; do | |
read QUERY | |
if [[ $QUERY == "" ]] | |
then exit | |
fi | |
QUERY_RESULT=$($LISTGEN "$QUERY" 2>/dev/null) | |
done | |
echo "$QUERY_RESULT" | cat -n | |
read QUERY_CHOICE | |
if [[ $QUERY_CHOICE == "" ]]; then | |
exit | |
fi | |
$HANDLER "$(echo "$QUERY_RESULT" | awk NR==$QUERY_CHOICE)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment