commit 532d1aaddba6490eff84d2b85c39d86d258ebc7f Author: Xavi Date: Wed Mar 15 16:57:56 2023 -0700 Added notetaking script 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" + +