From e4ea00cfc9fc7340c62dd920b4754787c4499de6 Mon Sep 17 00:00:00 2001 From: filip <“filip.rabiega@gmail.com”> Date: Thu, 10 Jul 2025 12:24:33 +0200 Subject: new scripts i guess --- newscript | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'newscript') diff --git a/newscript b/newscript index ef450a5..c251e20 100755 --- a/newscript +++ b/newscript @@ -1,21 +1,16 @@ #!/bin/sh -newscript () -{ - local name=$1 - cd ~/.scripts && touch "$name" && printf "#!/bin/sh\n\n" > "$name" && vim +2 "$name" - local linecount=$(wc -l < $HOME/.scripts/$name) - if [ "$linecount" -lt 2 ]; then - rm -f "$HOME/.scripts/$name" +newscript () { + path="$HOME/.scripts/$1" + touch "$path" && printf "#!/bin/sh\n\n" > "$path" && "$EDITOR" +2 "$path" + if [ "$( wc -l "$path" | awk '{print $1}' )" -lt 3 ]; then + rm -f "$path" else - chmod +x "$name" && cd - + chmod +x "$path" fi } -if [ $# -ne 1 ]; then - echo "Usage: newscript " - exit 1 -fi +[ "$#" -ne 1 ] && { echo "Usage: newscript " >&2; exit 1; } -newscript $1 +newscript "$1" exit 0 -- cgit v1.2.3