diff options
author | filip <“filip.rabiega@gmail.com”> | 2025-07-03 21:27:06 +0200 |
---|---|---|
committer | filip <“filip.rabiega@gmail.com”> | 2025-07-03 21:27:06 +0200 |
commit | 1feb678fc3d52a7a3c4e31bb153783852fa08a58 (patch) | |
tree | 9fdd767c7a3324440b96477e64d2cf9b8f62494b /newscript | |
parent | 54a39b322d1e13911d8f03d533ee1ed1a2af17d5 (diff) | |
download | chadscripts-1feb678fc3d52a7a3c4e31bb153783852fa08a58.tar.gz chadscripts-1feb678fc3d52a7a3c4e31bb153783852fa08a58.tar.bz2 chadscripts-1feb678fc3d52a7a3c4e31bb153783852fa08a58.zip |
added new stuff
Diffstat (limited to 'newscript')
-rwxr-xr-x | newscript | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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 |