diff options
Diffstat (limited to 'newscript')
-rwxr-xr-x | newscript | 21 |
1 files changed, 8 insertions, 13 deletions
@@ -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 |