diff options
Diffstat (limited to 'newscript')
-rwxr-xr-x | newscript | 11 |
1 files changed, 6 insertions, 5 deletions
@@ -1,12 +1,13 @@ #!/bin/sh 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" + file="$HOME/.scripts/$1" + [ -f "$file" ] && { echo "Script with the same name already exists, exiting" >&2; exit 1 ;} + touch "$file" && printf "#!/bin/sh\n\n" > "$file" && "$EDITOR" +2 "$file" + if [ "$( wc -l "$file" | awk '{print $1}' )" -lt 3 ]; then + rm -f "$file" else - chmod +x "$path" + chmod +x "$file" fi } |