diff options
author | filip <“filip.rabiega@gmail.com”> | 2025-07-10 12:24:33 +0200 |
---|---|---|
committer | filip <“filip.rabiega@gmail.com”> | 2025-07-10 12:24:33 +0200 |
commit | e4ea00cfc9fc7340c62dd920b4754787c4499de6 (patch) | |
tree | 2e4c036888529e99cd67a0ee59d9ac8bb5e09000 /newscript | |
parent | 1feb678fc3d52a7a3c4e31bb153783852fa08a58 (diff) | |
download | chadscripts-e4ea00cfc9fc7340c62dd920b4754787c4499de6.tar.gz chadscripts-e4ea00cfc9fc7340c62dd920b4754787c4499de6.tar.bz2 chadscripts-e4ea00cfc9fc7340c62dd920b4754787c4499de6.zip |
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 |