diff --git a/starta.sh b/starta.sh index a8d6934..6460510 100644 --- a/starta.sh +++ b/starta.sh @@ -14,7 +14,6 @@ CMD parameters available: " FOLDER="$HOME/.local/etc/starta" -MENU=0 addScript() { [ -z $NAME ] && echo "No script name provided. Exiting..." && exit 1 @@ -50,9 +49,21 @@ removeScript() { exit 1 } +editScript() { + [ -z $NAME ] && echo "No script name provided. Exiting..." && exit 1 + SCRIPT="${FOLDER}/${NAME}" + if [ -f "$SCRIPT" ] + then + $EDITOR "$SCRIPT" + exit 0 + fi + echo "Script not found" + exit 1 +} + listScripts() { list=$(command ls "$FOLDER" 2>/dev/null) || error=1 - [ -z $list ] && error=1 + [[ -z $list ]] && error=1 if [ $error ] then echo "No scripts found! Add one with the '--add' option" @@ -75,6 +86,10 @@ else -r|--remove) NAME="$2" removeScript + ;; + -e|--edit) + NAME="$2" + editScript exit 0 ;; -h|--help)