Last active
March 27, 2023 00:59
-
-
Save thcipriani/7efb15b2057fe6348b45df26a3e3c479 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# journal.sh | |
# ========== | |
# | |
# One daily text file to rule them all. | |
# | |
# Copyright: 2022 Tyler Cipriani <[email protected] | |
# License: GPLv3 | |
set -euo pipefail | |
DATE="$(date --iso-8601=date)" | |
DATETIME="$(date --iso-8601=seconds)" | |
BASE="$HOME"/Documents/brain | |
WEBROOT="$HOME"/public_html/brain | |
mkdir -p "$BASE" | |
mkdir -p "$WEBROOT" | |
DAILY="$BASE"/"$DATE".md | |
DAILY_HTML="$WEBROOT"/"$DATE".html | |
has?() { | |
command -v "$@" &> /dev/null | |
} | |
insert() { | |
echo "$@" >> "$DAILY" | |
} | |
if [ ! -f "$DAILY" ]; then | |
insert '---' | |
insert "title: ${DATETIME}" | |
insert "created: ${DATETIME}" | |
insert '---' | |
insert '' | |
fi | |
vim -c 'Goyo' '+normal Go' "$DAILY" | |
has? pandoc && pandoc -s -f markdown -t html5 -o "$DAILY_HTML" "$DAILY" || : |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool little tool! I too created my own small notetaking program that creates a file with the current date as its name (you can create named notes too). The idea came after reading this post.