Added notetaking script

This commit is contained in:
Xavi 2023-03-15 16:57:56 -07:00
commit 532d1aaddb

29
notes.sh Executable file
View File

@ -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"