blob: 3d492df2f7625f3cbb7558b7bf1075287a38c4b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/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"
|