Lowering Barriers to Writing
----------------------------
Sun Nov 21 10:21:16 EST 2021
---
Sipping coffee and listening to Psychedelic Swamp on the
turntable while Jennie shops online for plants as presents.
---
When I moved from mdoc(7) over HTTP to plaintext over Gopher,
the barrier to writing became much smaller. No longer did I
have to look up the mdoc man page while writing, nor did I
have to check how it looked in multiple formats (HTML and
ASCII). There were also psychological barriers too--a phlog
has less traffic, and the traffic here is maybe less judgey.
I feel I can be a bit more open in my writing and worry about
the phrasing less.
I wanted to make it even easier to "just start writing", so
I wrote a small shell script "phlog(1)" that:
1. Takes a title
2. Starts a new entry at the next NNN.txt file available
3. Prepopulates the entry with the title and date
4. Updates the phlog index to include the entry
It's in
gopher://alexkarle.com/1/code, but I wanted to include
it here too, just because I expect it'll morph over time and
I want to document the MVP!
Some things learned:
- `$(())` for arithmetic returns the result, so to avoid
executing a number, prefix it with the null operation `:`
- ed(1) is awesome for programmatic edits to files
--- phlog(1) ---
#!/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" <<EOM
/^\[0|Atom Feed/+a
[0|[$(date +%F)] $title|/phlog/$file|server|port]
wq
EOM
exec "${EDITOR:-vi}" "$PHLOG/$file"