From 532d1aaddba6490eff84d2b85c39d86d258ebc7f Mon Sep 17 00:00:00 2001 From: Xavi Date: Wed, 15 Mar 2023 16:57:56 -0700 Subject: [PATCH] Added notetaking script --- notes.sh | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100755 notes.sh diff --git a/notes.sh b/notes.sh new file mode 100755 index 0000000..a633358 --- /dev/null +++ b/notes.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# Set Notes Directory Here +NOTES_DIR="$HOME/.notes" + +# Default note name if no args are passed in +FILE_NAME="quicknote" + +# If arg is passed, used arg as file name +if [ -n "$1" ]; then + FILE_NAME="$1" +fi + +# Check if name exists, if it does append and increment +# COUNTER until no collision detected +COUNTER=2 +TEMP_NAME=$FILE_NAME +while [ -e "$NOTES_DIR/$TEMP_NAME.md" ]; do + TEMP_NAME="$FILE_NAME$COUNTER" + COUNTER=$((COUNTER+1)) +done + +# prepend note directory and make a markdown file +FILE_NAME="$NOTES_DIR/$TEMP_NAME.md" + +# open file in vim +vim "$FILE_NAME" + +