From 8ba21a2421b8ab2c2857d56ee119dfc1a3dc9104 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sun, 21 Nov 2021 10:58:30 -0500 Subject: [PATCH] gopher: Add script to automate phlogging & entry about it Ah the classic "blog trap" -- it's more fun to automate blogging than to blog itself! Here's to hoping I can make it so dead simple to phlog that I don't fall into this trap again... --- gopher/bin/phlog | 38 ++++++++++++++++++++++++++++++++++++++ gopher/phlog/011.txt | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gopher/phlog/index.gph | 1 + 3 files changed, 116 insertions(+) create mode 100755 gopher/bin/phlog create mode 100644 gopher/phlog/011.txt diff --git a/gopher/bin/phlog b/gopher/bin/phlog new file mode 100755 index 0000000..7247185 --- /dev/null +++ b/gopher/bin/phlog @@ -0,0 +1,38 @@ +#!/bin/sh +# phlog -- lowering the barrier to phlogging +# see gopher://alexkarle.com/phlog/011.txt +die() { + echo "$*" + exit 1 +} + +[ -z "$1" ] && die "usage: phlog TITLE" + +PHLOG=$(dirname "$(dirname "$(readlink -f "$0")")")/phlog + +i=1 +nextfile() { + file=$(printf "%03d.txt" $i) + : $((i+=1)) +} + +title="$*" +underline="$(echo "$title" | sed 's/./-/g')" + +nextfile +while [ -e "$PHLOG/$file" ]; do + nextfile +done + +echo "$title" >"$PHLOG/$file" +echo "$underline" >>"$PHLOG/$file" +date >>"$PHLOG/$file" + +ed "$PHLOG/index.gph" <"$PHLOG/$file" +echo "$underline" >>"$PHLOG/$file" +date >>"$PHLOG/$file" + +ed "$PHLOG/index.gph" <