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"
|
FOLDER="$HOME/.local/etc/starta"
|
||||||
MENU=0
|
|
||||||
|
|
||||||
addScript() {
|
addScript() {
|
||||||
[ -z $NAME ] && echo "No script name provided. Exiting..." && exit 1
|
[ -z $NAME ] && echo "No script name provided. Exiting..." && exit 1
|
||||||
@ -50,9 +49,21 @@ removeScript() {
|
|||||||
exit 1
|
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() {
|
listScripts() {
|
||||||
list=$(command ls "$FOLDER" 2>/dev/null) || error=1
|
list=$(command ls "$FOLDER" 2>/dev/null) || error=1
|
||||||
[ -z $list ] && error=1
|
[[ -z $list ]] && error=1
|
||||||
if [ $error ]
|
if [ $error ]
|
||||||
then
|
then
|
||||||
echo "No scripts found! Add one with the '--add' option"
|
echo "No scripts found! Add one with the '--add' option"
|
||||||
@ -75,6 +86,10 @@ else
|
|||||||
-r|--remove)
|
-r|--remove)
|
||||||
NAME="$2"
|
NAME="$2"
|
||||||
removeScript
|
removeScript
|
||||||
|
;;
|
||||||
|
-e|--edit)
|
||||||
|
NAME="$2"
|
||||||
|
editScript
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-h|--help)
|
-h|--help)
|
||||||
|
Loading…
Reference in New Issue
Block a user