Created
April 13, 2016 21:59
-
-
Save michaelstephens/496d325384528d39a702e72b7a2c7a8a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| 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 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Create a
UDE_PATHexport to make this work