feat: added edit script function
This commit is contained in:
parent
b0d2ea608a
commit
4248d15444
19
starta.sh
19
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)
|
||||
|
Loading…
Reference in New Issue
Block a user