Skip to content

Instantly share code, notes, and snippets.

@mohamed
Forked from thcipriani/journal.sh
Created June 17, 2022 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mohamed/d3a4fb8f289796eda341e6688553e4c2 to your computer and use it in GitHub Desktop.
Save mohamed/d3a4fb8f289796eda341e6688553e4c2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# journal.sh
# ==========
#
# One daily text file to rule them all.
#
# Copyright: 2022 Tyler Cipriani <tyler@tylercipriani.com
# 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