Skip to content

Instantly share code, notes, and snippets.

@ruario

ruario/ejnl.sh Secret

Last active Sep 15, 2022
Embed
What would you like to do?
Script to extract the latest entry of my Gemini journal
#!/bin/sh -eu
JSTART="$(grep -m1 '^## ' journal.gmi | cut -d' ' -f2)"
JTIME="$(grep -m1 '^### ' journal.gmi | cut -d' ' -f2-)"
JEND="$(grep -m3 '^\(##\|⁂\)' journal.gmi | tail -n 1 | cut -d' ' -f2)"
JOUTPUT="journal-extract-${JSTART}-$(echo "$JTIME" | cut -d' ' -f1 | tr -d ':').gmi"
{
echo "# Ruario's Journal [extract]"
sed -n "/^## $JSTART/,/^##* $JEND/p" journal.gmi | sed '$d'
printf "⁂\n\n=> journal.gmi 📝 Journal [complete]\n"
} > "$JOUTPUT"
echo "Created: $JOUTPUT"
cat <<EOF> journal-feed.gmi
# ruario
=> $JOUTPUT $JSTART @${JTIME}$(grep -Em1 '^[[:alnum:]\>=@\'\"~]' $JOUTPUT | sed -E 's/^=>[[:blank:]]*[^[:blank:]]+[[:blank:]]+//' | cut -c 1-49 | sed 's/$/…/')
EOF
echo "Created: journal-feed.gmi"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment