Skip to content

Instantly share code, notes, and snippets.

@michaelstephens
Created April 13, 2016 21:59
Show Gist options
  • Save michaelstephens/496d325384528d39a702e72b7a2c7a8a to your computer and use it in GitHub Desktop.
Save michaelstephens/496d325384528d39a702e72b7a2c7a8a to your computer and use it in GitHub Desktop.
function atom-ude() {
if [[ $1 == /* ]]; then
atom $UDE_PATH$1;
else
local pth="$(find $UDE_PATH -depth -maxdepth 2 -name "*$1*")"
if [ -z "$pth" ]; then
echo "$1 not found.";
else
echo "Please choose an option:";
COUNTER=0
for p in $(find $UDE_PATH -depth -maxdepth 2 -name "*$1*"); do
let COUNTER+=1
echo "$COUNTER : ${p#${UDE_PATH}}"
done
echo "Enter to choose, exit to quit"
echo -n "[CHOICE]: "
read choice
while ! [[ "$choice" =~ ^[1-$COUNTER]+$ ]]; do
if [ "$choice" =~ "exit" ]; then
echo "Quitting..."
return
fi
echo "$choice is not a valid choice."
echo -n "[CHOICE]: "
read choice
done
COUNTER=0
for p in $(find $UDE_PATH -depth -maxdepth 2 -name "*$1*"); do
let COUNTER+=1
if [ $COUNTER -eq $choice ]; then
atom $p
break
fi
done
fi
fi
}
@michaelstephens
Copy link
Author

Create a UDE_PATH export to make this work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment