diff options
Diffstat (limited to 'newnote')
-rwxr-xr-x | newnote | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -0,0 +1,17 @@ +#!/bin/sh + +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 +} + +[ "$#" -ne 1 ] && { echo "Usage: newnote <note-name>" >&2; exit 1; } + +newnote "$1" +exit 0 |