aboutsummaryrefslogtreecommitdiff
path: root/note
diff options
context:
space:
mode:
Diffstat (limited to 'note')
-rwxr-xr-xnote21
1 files changed, 21 insertions, 0 deletions
diff --git a/note b/note
new file mode 100755
index 0000000..3d492df
--- /dev/null
+++ b/note
@@ -0,0 +1,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"