--- -	2006-07-20 23:17:54.000000000 +0200
+++ /dev/fd/63	2006-07-20 23:17:54.000000000 +0200
@@ -1,8 +1,5 @@
 #! /bin/sh
 
-# NOTE:  Todo.sh requires the .todo configuration file to run.
-# Place the .todo file in your home directory or use the -d option for a custom location.
-
 version() { sed -e 's/^    //' <<EndVersion
         TODO.TXT Manager
         Version 1.7
@@ -151,6 +148,21 @@
 
 . "$CFG_FILE"
 
+thisweek=$(date '+%Y-%W')
+today=$(date '+%Y/%m/%d')
+thisyear=$(date '+%Y')
+CMD=$(echo $0 | sed 's/\(.*\)\///')
+
+
+if [[ $CMD != "manager" ]]; then
+	TODO_FILE="$TODO_DIR/list$CMD.txt"
+	DONE_FILE="$TODO_DIR/archive/$CMD/$thisweek.txt"  
+	REPORT_FILE="$TODO_DIR/archive/$CMD/report$thisyear.txt"
+	else
+		echo $0
+		echo $CMD
+	fi
+
 [ -z "$1" ]         && usage
 [ -d "$TODO_DIR" ]  || die "Fatal Error: $TODO_DIR is not a directory"  
 cd "$TODO_DIR"      || die "Fatal Error: Unable to cd to $TODO_DIR"
@@ -217,38 +229,38 @@
 	cleanup;;
 
 "archive" )
-	[[ $VERBOSE = 1 ]] && grep "^x " "$TODO_FILE"
-	grep "^x " "$TODO_FILE" >> "$DONE_FILE"
-	sed -i.bak '/^x /d' "$TODO_FILE"
-        [[ $VERBOSE = 1 ]] && echo "--"
-        [[ $VERBOSE = 1 ]] && echo "TODO:  Items marked as done have been moved from $TODO_FILE to $DONE_FILE."
+	[[ $VERBOSE = 1 ]] &&  grep "^x:done " "$TODO_FILE"
+	sed '/^x:done /!d' "$TODO_FILE" | sed 's/^x:done //' >> "$DONE_FILE"
+	sed -i.bak '/^x:done /d' "$TODO_FILE"
+        [[ $VERBOSE = 1 ]] &&  echo "--"
+        [[ $VERBOSE = 1 ]] &&  echo "TODO:  Items marked as done have been moved from $TODO_FILE to $DONE_FILE."
 	cleanup;;
 
 "del" )
-	errmsg="usage: $0 del ITEM#"
-	item=$2
-	[ -z "$item" ] && die "$errmsg"
-	[[ "$item" = +([0-9]) ]] || die "$errmsg"
-	if sed -ne "$item p" "$TODO_FILE" | grep "^."; then
-		DELETEME=$(sed "$2!d" "$TODO_FILE")
-
-		if  [ $FORCE = 0 ]; then
-		    echo "Delete '$DELETME'?  (y/n)"
-			read ANSWER
-		else
-			ANSWER="y"
-		fi
-		
-	    if [ "$ANSWER" = "y" ]; then
-		       sed -i.bak -e $2"s/^.*//" -e '/./!d' "$TODO_FILE"
-		       [[ $VERBOSE = 1 ]] && echo "TODO:  '$DELETEME' deleted."
-		       cleanup
+		errmsg="usage: $0 del ITEM#"
+		item=$2
+		[ -z "$item" ] && die "$errmsg"
+		[[ "$item" = +([0-9]) ]] || die "$errmsg"
+		if sed -ne "$item p" "$TODO_FILE" | grep "^."; then
+			DELETEME=$(sed "$2!d" "$TODO_FILE")
+
+			if  [ $FORCE = 0 ]; then
+			    echo "Delete '$DELETME'?  (y/n)"
+				read ANSWER
+			else
+				ANSWER="y"
+			fi
+
+		    if [ "$ANSWER" = "y" ]; then
+			       sed -i.bak -e $2"s/^.*//" -e '/./!d' "$TODO_FILE"
+			       [[ $VERBOSE = 1 ]] && echo "TODO:  '$DELETEME' deleted."
+			       cleanup
+			else
+				echo "TODO:  No tasks were deleted."
+			fi
 		else
-			echo "TODO:  No tasks were deleted."
-		fi
-	else
-		echo "$item: No such todo."
-        fi ;;
+			echo "$item: No such todo."
+	        fi ;;
 
 "do" )
 	errmsg="usage: $0 do ITEM#"
@@ -257,11 +269,10 @@
 	[[ "$item" = +([0-9]) ]] || die "$errmsg"
 
 	if sed -ne "$item p" "$TODO_FILE" | grep "^."; then
-		now=`date '+%Y-%m-%d'`
-		sed -i.bak $2"s|^|&x $now |" "$TODO_FILE"
+		sed -i.bak $2"s|^|x:done &$today |" "$TODO_FILE"
 		NEWTODO=$(sed "$2!d" "$TODO_FILE")
-	        [[ $VERBOSE = 1 ]] && echo "$item: $NEWTODO"
-	        [[ $VERBOSE = 1 ]] && echo "TODO: $item marked as done."
+	        [[ $VERBOSE = 1 ]] &&  echo "$item: $NEWTODO"
+	        [[ $VERBOSE = 1 ]] &&  echo "TODO: $item marked as done."
 		cleanup
 	else
 		echo "$item:  No such todo."
@@ -270,12 +281,13 @@
 "list" )
 	item=$2
 	if [ -z "$item" ]; then
-		echo -e "`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1 /' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/'`"
+		# Now in COLOR!  with padding!
+		echo -e "`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1 /' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9] x:done /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/'`"
 		echo "--"
 		NUMTASKS=$(wc -l "$TODO_FILE" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
 		echo "TODO: $NUMTASKS tasks in $TODO_FILE."
 	else
-		command=`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1 /' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/' | grep -i $item `
+		command=`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1  /' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9] x:done /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/' | grep -i $item `
 		shift
 		shift
 		for i in $*
@@ -289,60 +301,60 @@
 	cleanup ;;
 
 "listall" )
-	item=$2
-    cat "$TODO_FILE" "$DONE_FILE" > "$TMP_FILE"
+		item=$2
+	    #cat "$TODO_FILE" "$DONE_FILE" > "$TMP_FILE"
 
-	if [ -z "$item" ]; then
-		echo -e "`sed = "$TMP_FILE" | sed 'N; s/^/  /; s/ *\(.\{3,\}\)\n/\1 /' | sed 's/^  /00/' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/'`"
-	else
-		command=`sed = "$TMP_FILE" | sed 'N; s/^/  /; s/ *\(.\{3,\}\)\n/\1 /' | sed 's/^  /00/' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/' | grep -i $item `
-		shift
-		shift
-		for i in $*
-			do
-			command=`echo "$command" | grep -i $i `
-			done
-		command=`echo "$command" | sort -f -k2`
+		if [ -z "$item" ]; then
+			echo -e "`sed = "$TODO_FILE" "$DONE_FILE" | sed 'N; s/^/  /; s/ *\(.\{3,\}\)\n/\1 /' | sed 's/^  /00/' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/'`"
+		else
+			command=`sed = "$TODO_FILE" "$DONE_FILE" | sed 'N; s/^/  /; s/ *\(.\{3,\}\)\n/\1 /' | sed 's/^  /00/' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/' | grep -i $item `
+			shift
+			shift
+			for i in $*
+				do
+				command=`echo "$command" | grep -i $i `
+				done
+			command=`echo "$command" | sort -f -k2`
 
-		echo -e "$command"
-	fi
-	cleanup ;;
+			echo -e "$command"
+		fi
+		cleanup ;;
 
 "listpri" )
 	pri=$2
 	if [ -z "$pri" ]; then
-		echo -e "`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1 /' | sed 's/^ /0/' | sort -f -k2 |  sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/'`" | grep \([A-Z]\)
+		echo -e "`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1  /' | sed 's/^ /0/' | sort -f -k2 |  sed '/^[0-9][0-9] x:done /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/'`" | grep \([A-Z]\)
 	else
-		echo -e "`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1 /' | sed 's/^ /0/' |  sort -f -k2 |  sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/'`" | grep \($pri\)
+		echo -e "`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1  /' | sed 's/^ /0/' |  sort -f -k2 |  sed '/^[0-9][0-9] x:done /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x:done /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/'`" | grep \($pri\)
 	fi
 	cleanup;;
 
-"prepend" )
-	errmsg="usage: $0 prepend ITEM# \"TEXT TO PREPEND\""
-	shift; item=$1; shift
-	
-	[ -z "$item" ] && die "$errmsg"
-	[[ "$item" = +([0-9]) ]] || die "$errmsg"
-
-	if [[ -z "$1" && $FORCE = 0 ]]; then
-		echo -n "Prepend: "
-		read input
-	else
-		input=$*
-	fi
+	"prepend" )
+		errmsg="usage: $0 prepend ITEM# \"TEXT TO PREPEND\""
+		shift; item=$1; shift
+
+		[ -z "$item" ] && die "$errmsg"
+		[[ "$item" = +([0-9]) ]] || die "$errmsg"
+
+		if [[ -z "$1" && $FORCE = 0 ]]; then
+			echo -n "Prepend: "
+			read input
+		else
+			input=$*
+		fi
 
 
-	if sed -ne "$item p" "$TODO_FILE" | grep "^."; then
-		if sed -i.bak $item" s|^.*|$input &|" "$TODO_FILE"; then
-		        NEWTODO=$(sed "$item!d" "$TODO_FILE")
-		        echo "$item: $NEWTODO"
+		if sed -ne "$item p" "$TODO_FILE" | grep "^."; then
+			if sed -i.bak $item" s|^.*|$input &|" "$TODO_FILE"; then
+			        NEWTODO=$(sed "$item!d" "$TODO_FILE")
+			        echo "$item: $NEWTODO"
+			else
+				echo "TODO:  Error prepending task $item."
+			fi
 		else
-			echo "TODO:  Error prepending task $item."
+			echo "$item: No such todo."
 		fi
-	else
-		echo "$item: No such todo."
-	fi
-	cleanup;;
+		cleanup;;
 "pri" )
 	item=$2
 	newpri=$3
@@ -359,9 +371,9 @@
 		#it's all good, continue
 		sed -i.bak -e $2"s/^(.*) //" -e $2"s/^/($3) /" "$TODO_FILE"
                 NEWTODO=$(sed "$2!d" "$TODO_FILE")
-		[[ $VERBOSE = 1 ]] && echo -e "`echo "$item: $NEWTODO"`"
+		[[ $VERBOSE = 1 ]] &&  echo -e "`echo "$item: $NEWTODO"`"
                 
-                [[ $VERBOSE = 1 ]] && echo "TODO: $item prioritized ($newpri)."
+                [[ $VERBOSE = 1 ]] &&  echo "TODO: $item prioritized ($newpri)."
 		cleanup
         else
 		die "$errmsg"
@@ -369,37 +381,72 @@
 "remdup" )
 	cp "$TODO_FILE" "$TMP_FILE"
 	cat "$TMP_FILE" | sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' > "$TODO_FILE"
-	[[ $VERBOSE = 1 ]] && echo "TODO: Duplicate tasks have been removed."
+	[[ $VERBOSE = 1 ]] &&  echo "TODO: Duplicate tasks have been removed."
 	cleanup;;
 
 "replace" )
 	errmsg="usage: $0 replace ITEM# \"UPDATED ITEM\""
 	shift; item=$1; shift
-
 	[ -z "$item" ] && die "$errmsg"
 	[[ "$item" = +([0-9]) ]] || die "$errmsg"
 	
-	if [[ -z "$1" && $FORCE = 0 ]]; then
-		echo -n "Replacement: "
-		read input
-	else
-		input=$*
-	fi
-	
 	if sed -ne "$item p" "$TODO_FILE" | grep "^."; then
-		sed -i.bak $item" s|^.*|$input|" "$TODO_FILE"
-		[[ $VERBOSE = 1 ]] && NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
-		[[ $VERBOSE = 1 ]] && echo "replaced with"
-		[[ $VERBOSE = 1 ]] && echo "$item: $NEWTODO"
+		# made the sed delimiter a pipe | b/c you might want to add text with slashes, like a URL
+		# TODO: check if incoming text contains a pipe and escape it
+		sed -i.bak $item" s|^.*|$*|" "$TODO_FILE"
+		[[ $VERBOSE = 1 ]] &&  NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
+		[[ $VERBOSE = 1 ]] &&  echo "replaced with"
+		[[ $VERBOSE = 1 ]] &&  echo "$item: $NEWTODO"
 	else
 		echo "$item: No such todo."
 	fi
 	cleanup;;
+	
+"tickle" )
 
+item=$2;
+[ -z "$item" ] && die "$errmsg"
+[[ "$item" = +([0-9]) ]] || die "$errmsg"
+
+datetype=$3; 
+
+if [ -z "$datetype" ]; then
+			    echo "Tickle to day or month folder?  (d/m)"
+				read ANSWER
+			    if [ "$ANSWER" = "d" ]; then
+						FOLDER="days"
+					echo "Tickle to which day folder?"
+					read NUMBER
+				elif [ "$ANSWER" = "m" ]; then
+						FOLDER="months"
+				echo "Tickle to which month folder?"
+				read NUMBER
+				fi
+else
+if expr "$datetype" : ' *[dD].*' > /dev/null; then
+FOLDER="days"
+NUMBER="`echo $datetype | sed 's/d//'`"
+elif expr "$datetype" : ' *[mM].*' > /dev/null; then
+	FOLDER="months"
+NUMBER="`echo $datetype | sed 's/m//'`"
+fi
+fi
+LENGTH=`expr "$NUMBER" : ".*"`
+if [ "$LENGTH" = "1" ]; then
+	NUMBER="0$NUMBER"
+fi
+if sed -ne "$item p" "$TODO_FILE" | grep "^."; then
+	DELETEME=$(sed "$item!d" "$TODO_FILE")
+fi
+echo $DELETEME >> $TICKLER_DIR/$TYPE/$FOLDER/$NUMBER/$NUMBER.txt
+sed -i.bak -e $2"s/^.*//" -e '/./!d' "$TODO_FILE"
+echo "Moved todo $2 to $TICKLER_DIR/$TYPE/$FOLDER/$NUMBER/$NUMBER.txt"
+cleanup;;
+			
 "report" )
 	#archive first
-	sed '/^x /!d' "$TODO_FILE" >> $DONE_FILE
-	sed -i.bak '/^x /d' "$TODO_FILE"
+	sed '/^x:done /!d' "$TODO_FILE" | sed 's/^x:done //' >> "$DONE_FILE"
+	sed -i.bak '/^x:done /d' "$TODO_FILE"
 
     NUMLINES=$(wc -l "$TODO_FILE" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
     if [ $NUMLINES = "0" ]; then
@@ -411,9 +458,10 @@
 	TECHO=$(echo $(date +%Y-%m-%d-%T); echo ' '; echo $TOTAL; echo ' ';
 	echo $TDONE)
 	echo $TECHO >> "$REPORT_FILE"
-	[[ $VERBOSE = 1 ]] && echo "TODO:  Report file updated."
+	[[ $VERBOSE = 1 ]] &&  echo "TODO:  Report file updated."
 	cat "$REPORT_FILE"
 	cleanup;;
+
 * )
 	usage
-esac
+esac
\ No newline at end of file
