summaryrefslogtreecommitdiff
path: root/newscript
diff options
context:
space:
mode:
authorfilip <“filip.rabiega@gmail.com”>2025-07-10 12:24:33 +0200
committerfilip <“filip.rabiega@gmail.com”>2025-07-10 12:24:33 +0200
commite4ea00cfc9fc7340c62dd920b4754787c4499de6 (patch)
tree2e4c036888529e99cd67a0ee59d9ac8bb5e09000 /newscript
parent1feb678fc3d52a7a3c4e31bb153783852fa08a58 (diff)
downloadchadscripts-e4ea00cfc9fc7340c62dd920b4754787c4499de6.tar.gz
chadscripts-e4ea00cfc9fc7340c62dd920b4754787c4499de6.tar.bz2
chadscripts-e4ea00cfc9fc7340c62dd920b4754787c4499de6.zip
new scripts i guessHEADmaster
Diffstat (limited to 'newscript')
-rwxr-xr-xnewscript21
1 files changed, 8 insertions, 13 deletions
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 <script-name>"
- exit 1
-fi
+[ "$#" -ne 1 ] && { echo "Usage: newscript <script-name>" >&2; exit 1; }
-newscript $1
+newscript "$1"
exit 0