phlog (652B) [raw]
1 #!/bin/sh 2 # phlog -- lowering the barrier to phlogging 3 # see gopher://alexkarle.com/phlog/011.txt 4 die() { 5 echo "$*" 6 exit 1 7 } 8 9 [ -z "$1" ] && die "usage: phlog TITLE" 10 11 PHLOG=$(dirname "$(dirname "$(readlink -f "$0")")")/phlog 12 13 i=1 14 nextfile() { 15 file=$(printf "%03d.txt" $i) 16 : $((i+=1)) 17 } 18 19 title="$*" 20 underline="$(echo "$title" | sed 's/./-/g')" 21 22 nextfile 23 while [ -e "$PHLOG/$file" ]; do 24 nextfile 25 done 26 27 echo "$title" >"$PHLOG/$file" 28 echo "$underline" >>"$PHLOG/$file" 29 date >>"$PHLOG/$file" 30 31 ed "$PHLOG/index.gph" <<EOM 32 /^\[0|Atom Feed/+a 33 [0|[$(date +%F)] $title|/phlog/$file|server|port] 34 . 35 wq 36 EOM 37 38 exec "${EDITOR:-vi}" "$PHLOG/$file"