#!/bin/bash
#                                ~/bin/today
#                       /usr/local/bin/today
# https://crystalfaeries.net/posix/bin/today
# celeste:crystalfaery TODAY 2017-10-11 18:28:34+00:00
# Initiate today's blog entry from template

cd	# there's no place like $HOME
if [ -f			~/crystalfaeries.net/src/$(date --rfc-3339=date).fae.txt ]
then
	echo "...editing today's blog entry file" 1>&2
	vi		~/crystalfaeries.net/src/$(date --rfc-3339=date).fae.txt
	todo
	exit $?
else
    if [ -f		~/crystalfaeries.net/src/.$(date --rfc-3339=date).fae.txt ]
    then
	echo "...editing today's pre-publish file" 1>&2
	rsync -auvzH	~/crystalfaeries.net/src/.$(date --rfc-3339=date).fae.txt	\
			~/crystalfaeries.net/src/$(date --rfc-3339=date).fae.txt
	vi		~/crystalfaeries.net/src/$(date --rfc-3339=date).fae.txt
	delete		~/crystalfaeries.net/src/.$(date --rfc-3339=date).fae.txt
	todo
	exit $?
    else
	echo "...creating today's blog entry file" 1>&2
	echo -n "Date:	"						\
			>  ~/crystalfaeries.net/src/$(date --rfc-3339=date).fae.txt
	now		>> ~/crystalfaeries.net/src/$(date --rfc-3339=date).fae.txt
	cat		   ~/crystalfaeries.net/src/.template.txt			\
			>> ~/crystalfaeries.net/src/$(date --rfc-3339=date).fae.txt
	vi		   ~/crystalfaeries.net/src/$(date --rfc-3339=date).fae.txt
	todo
	exit $?
    fi
fi
exit	$?


syntax highlighted by Code2HTML, v. 0.9.1