summaryrefslogtreecommitdiff
path: root/newscript
diff options
context:
space:
mode:
authorfilip <“filip.rabiega@gmail.com”>2025-07-03 21:27:06 +0200
committerfilip <“filip.rabiega@gmail.com”>2025-07-03 21:27:06 +0200
commit1feb678fc3d52a7a3c4e31bb153783852fa08a58 (patch)
tree9fdd767c7a3324440b96477e64d2cf9b8f62494b /newscript
parent54a39b322d1e13911d8f03d533ee1ed1a2af17d5 (diff)
downloadchadscripts-1feb678fc3d52a7a3c4e31bb153783852fa08a58.tar.gz
chadscripts-1feb678fc3d52a7a3c4e31bb153783852fa08a58.tar.bz2
chadscripts-1feb678fc3d52a7a3c4e31bb153783852fa08a58.zip
added new stuff
Diffstat (limited to 'newscript')
-rwxr-xr-xnewscript18
1 files changed, 13 insertions, 5 deletions
diff --git a/newscript b/newscript
index 709d592..ef450a5 100755
--- a/newscript
+++ b/newscript
@@ -2,12 +2,20 @@
newscript ()
{
- if [ -z "$1" ]; then
- echo "Usage: newscript <script-name>"
- return 1
- fi
local name=$1
- cd ~/.scripts && touch "$name" && printf "#!/bin/sh\n\n" > "$name" && vim +2 "$name" && chmod +x "$name" && cd -
+ 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"
+ else
+ chmod +x "$name" && cd -
+ fi
}
+if [ $# -ne 1 ]; then
+ echo "Usage: newscript <script-name>"
+ exit 1
+fi
+
newscript $1
+exit 0