summaryrefslogtreecommitdiff
path: root/newscript
diff options
context:
space:
mode:
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