#!/bin/bash
#                       /usr/local/bin/todo
# https://crystalfaeries.net/posix/bin/todo
# celeste:crystalfaery TODO 2021-04-12 16:11:48+00:00

# TODO list is comprised of:
#
# 1	todo items with extremely long names
#
# 2	"${HOME}"/crystalfaeries.net/src/.??*	blog articles	in development and TODO items	(newest first)
# 3	/usr/local/bin/.??*	scripts				in development and TODO items	(newest first)
#
# 4	/usr/local/bin/*	scripts				already active			(oldest first)
# 5	"${HOME}"/crystalfaeries.net/src/*	blog articles	already active			(oldest first)
# 6	"${HOME}"/crystalfaeries.net/imgs/{,*/}HEADER.html	image HEADER files		(oldest first)

# NOTE: cronjob runs at end of each month:
# 00	14	28	02	*	/usr/local/bin/chrontouch
# 00	14	30     9,4,6,11	*	/usr/local/bin/chrontouch
# 00	14	31     1,3,5,7	*	/usr/local/bin/chrontouch
# 00	14	31     8,10,12	*	/usr/local/bin/chrontouch
# so that user will find largest TODO files as most recent TODO files
#            and it also finally prioritizes the scripting TODOs

# NOTE: our working directory is primary home of todo items:
cd -P	"${HOME}"/crystalfaeries.net/src/	|| exit 255

let help=27	# 1 less than this line number in script

# start with TODO items with extremely long names:
	lsdir -r					| head	>> /tmp/.$$.txt
# then with the newest TODO items:
ls -t	"${HOME}"/crystalfaeries.net/src/.??*			\
	"${HOME}"/crystalfaeries.net/posix/bin/.??*		\
							| head	>  /tmp/.$$.txt
# then the oldest articles and scripts and documents:
ls -tr	"${HOME}"/crystalfaeries.net/src/*			\
	"${HOME}"/crystalfaeries.net/posix/bin/*		\
	"${HOME}"/crystalfaeries.net/posix/doc/txt/*		\
							| head	>> /tmp/.$$.txt
# then the oldest directory pages:
ls -tr	"${HOME}"/crystalfaeries.net/imgs/index.html		\
	"${HOME}"/crystalfaeries.net/imgs/*/HEADER.html		\
							| head	>> /tmp/.$$.txt
# then the oldest documents:
ls -tr	"${HOME}"/documents/txt/*				\
							| head	>> /tmp/.$$.txt

# excluding any deleted (size 0) files:
cp /dev/null							   /tmp/.$$.edit.txt
for f in `grep -v '.*.swp' /tmp/.$$.txt`
do
	if [ -s "${f}" ]
	then
		echo "${f}"					>> /tmp/.$$.edit.txt
	fi
done
rm								   /tmp/.$$.txt
vi							`cat	   /tmp/.$$.edit.txt`
rm								   /tmp/.$$.edit.txt
exit $?
