Skip to content

Instantly share code, notes, and snippets.

Created July 4, 2017 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/2dd555b3e98a78bcba42fa98210c8c1e to your computer and use it in GitHub Desktop.
Save anonymous/2dd555b3e98a78bcba42fa98210c8c1e to your computer and use it in GitHub Desktop.
#!/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