scripts/note

22 lines
561 B
Text
Raw Normal View History

2024-11-12 19:39:05 -05:00
#!/bin/sh
# note: Create a new note for the day, or add to an existing one.
DATE=$(date '+%F')
TIME=$(date '+%T')
NOTES_DIR="$HOME/documents/notes"
NOTE="$NOTES_DIR/${DATE}.md"
[ ! -d "$NOTES_DIR" ] && mkdir -p "$NOTES_DIR"
# Create a new note if it doesn't already exist, otherwise append to it.
if [ ! -f "$NOTE" ]; then
printf "# %s\n## %s\n\n" "$DATE" "$TIME" > "$NOTE"
else
printf "\n## %s\n\n" "$TIME" >> "$NOTE"
fi
# Open up the note with the cursor positioned at the bottom to easily allow
# additions to a new section.
${EDITOR:-vi} + "$NOTE"