From 4248d15444b84069436b179f7d798a68f77a975a Mon Sep 17 00:00:00 2001 From: Bruno Fontes Date: Tue, 18 Oct 2022 23:48:21 -0300 Subject: [PATCH] feat: added edit script function --- starta.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) 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)