diff options
author | filip <“filip.rabiega@gmail.com”> | 2025-10-10 19:10:02 +0200 |
---|---|---|
committer | filip <“filip.rabiega@gmail.com”> | 2025-10-10 19:10:02 +0200 |
commit | 807de46d3a3cbef9a3c3c104f6db87b142e6eed5 (patch) | |
tree | 61a1a9bc26daad623ce6c04bb66ae39133ef0261 /newnote | |
parent | 08204fc9b9f63015a1dc083b471c6839818eeb59 (diff) | |
download | chadscripts-807de46d3a3cbef9a3c3c104f6db87b142e6eed5.tar.gz chadscripts-807de46d3a3cbef9a3c3c104f6db87b142e6eed5.tar.bz2 chadscripts-807de46d3a3cbef9a3c3c104f6db87b142e6eed5.zip |
used shfmt
Diffstat (limited to 'newnote')
-rwxr-xr-x | newnote | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -2,16 +2,22 @@ dir="$HOME/.obsidian" -newnote () { - file="$dir/$1.md" - [ -f "$file" ] && { echo "Note with the same name already exists, exiting" >&2; exit 1 ;} - touch "$file" && "$EDITOR" +2 "$file" - if [ "$( wc -l "$file" | awk '{print $1}' )" -lt 2 ]; then - rm -f "$file" - fi +newnote() { + file="$dir/$1.md" + [ -f "$file" ] && { + echo "Note with the same name already exists, exiting" >&2 + exit 1 + } + touch "$file" && "$EDITOR" +2 "$file" + if [ "$(wc -l "$file" | awk '{print $1}')" -lt 2 ]; then + rm -f "$file" + fi } -[ "$#" -ne 1 ] && { echo "Usage: newnote <note-name>" >&2; exit 1; } +[ "$#" -ne 1 ] && { + echo "Usage: newnote <note-name>" >&2 + exit 1 +} newnote "$1" exit 0 |