#!/bin/sh
#
#  Created by duus on 2006-10-10.
# 
_SCRIPTNAME=whenlast
if [ "$1" = "version" ]
	then
	echo "$_SCRIPTNAME by duus"
	echo " a timestamper and timestamp reader for my regular activities (updating ipod, backing up, etc.) "
	echo " see whenlast help"
	else
# --- normal script here ---
#
__date=`date`
if [ "$1" = "" -o "$1" = "all" ] 
	then
	echo "==> Today is: $__date <=="
	echo " "
	if [ "$2" != "" ]
		then
		filelist=`ls ~/Documents/Lists/Last/ | grep $2`
		else
		filelist=`ls ~/Documents/Lists/Last/ `
	fi
	for i in $filelist
		do
		echo " "
		echo "==> showing last done $i <=="
		head ~/Documents/Lists/Last/$i | more
	done
elif [ "$1" = "write" -o "$1" = "w" ]
	then
	echo "==> writing last done $2 is $__date <=="
	date > ~/Documents/Lists/Last/$2.txt
elif [ "$1" = "show" -o "$1" = "s" ]
	then
	echo "==> showing last done $2 <=="
	cat ~/Documents/Lists/Last/$2.txt
elif [ "$1" = "remove" -o "$1" = "r" ]
	then 
	echo "==> removing file $2 <=="
	cat ~/Documents/Lists/Last/$2.txt
	mv ~/Documents/Lists/Last/$2.txt ~/Documents/Lists/Last/old/$2.txt
else
	echo "whenlast v 1.0 by duus			                          "
	echo "whenlast with no arguments shows the whole list of whenlasts"
	echo "in directory ~/Documents/Lists/Last                         "
	echo "                                                            "
	echo "whenlast (w)rite file                                       "
	echo "writes ~/Documents/Lists/Last/file.txt                      "
	echo "                                                            "
	echo "whenlast (s)how file                                        "
	echo "shows ~/Documents/Lists/Last/file.txt                       "
	echo "                                                            "
	echo "whenlast (r)emove file                                        "
	echo "removes ~/Documents/Lists/Last/file.txt                       "
fi
#
#
#
fi # end 'version'

