--- -	2006-06-29 11:54:57.000000000 +0200
+++ /dev/fd/63	2006-06-29 11:54:57.000000000 +0200
@@ -11,16 +11,19 @@
 # === EDIT FILE LOCATIONS BELOW ===
 
 # Your todo.txt directory
-TODO_DIR="/Users/gina/Documents/todo"  
+TODO_DIR="/Users/tannie/GTD"
+thisweek=$(date '+%Y-%W')
+today=$(date '+%Y/%m/%d')
+thisyear=$(date '+%Y')
 #TODO_DIR="C:/Documents and Settings/gina/My Documents"  
 
 # Your todo/done/report.txt locations
-TODO_FILE="$TODO_DIR/todo.txt"  
-DONE_FILE="$TODO_DIR/done.txt"  
-REPORT_FILE="$TODO_DIR/report.txt" 
-TMP_FILE="$TODO_DIR/todo.tmp" 
+#TODO_FILE="$TODO_DIR/todo.txt"  
+#DONE_FILE="$TODO_DIR/done.txt"  
+#REPORT_FILE="$TODO_DIR/report.txt" 
+#TMP_FILE="$TODO_DIR/todo.tmp" 
+# ------ edit these below! -------
 
-# == EDIT FILE LOCATIONS ABOVE ===
 
 # === COLOR MAP ===
 
@@ -45,10 +48,10 @@
 
 # === PRIORITY COLORS ===
 
-PRI_A=$YELLOW   # color for A priority
+PRI_A=$RED  # color for A priority
 PRI_B=$GREEN  # color for B priority
-PRI_C=$LIGHT_BLUE   # color for B priority
-PRI_X=$WHITE   # color for rest of them
+PRI_C=$PURPLE  # color for B priority
+PRI_X=$BLUE   # color for rest of them
 
 die()
 {
@@ -122,12 +125,28 @@
     exit 1
 }
 
+
+
+CMD=$(echo $0 | sed 's/\(.*\)\///')
+
+# --- edit location here ----
+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
+
+
+
 # === SANITY CHECKS (thanks Karl!) ===
 [ -z "$1" ]         && usage
 [ -d "$TODO_DIR" ]  || die "$TODO_DIR is not a directory"  
 cd "$TODO_DIR"      || die "Unable to cd to $TODO_DIR"
 
-echo '' > "$TMP_FILE" || die "unable to write in $TODO_DIR"  
+# echo '' > "$TMP_FILE" || die "unable to write in $TODO_DIR"  
 [ -f "$TODO_FILE" ] || cp /dev/null "$TODO_FILE"
 [ -f "$DONE_FILE" ] || cp /dev/null "$DONE_FILE"
 [ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE"
@@ -156,7 +175,7 @@
 	shift
 
 	echo "$*" >> "$TODO_FILE"
-	TASKNUM=$(wc -l "$TODO_FILE" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
+	TASKNUM=$(cat  "$TODO_FILE" | wc -l)
         echo "TODO: '$*' added on line $TASKNUM."
 	cleanup;;
 
@@ -182,9 +201,8 @@
 	cleanup;;
 
 "archive" )
-    grep "^x " "$TODO_FILE"
-	grep "^x " "$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"
         echo "--"
         echo "TODO:  Items marked as done have been moved from $TODO_FILE to $DONE_FILE."
 	cleanup;;
@@ -216,8 +234,7 @@
 	[[ "$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")
 	        echo "$item: $NEWTODO"
 	        echo "TODO: $item marked as done."
@@ -230,12 +247,12 @@
 	item=$2
 	if [ -z "$item" ]; then
 		# Now in COLOR!
-		echo -e "`sed 's/^/ /' "$TODO_FILE" | grep -n '' | sed 's/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed 's/\(.*(B).*\)/'$PRI_B'\1'$'/g' | sed 's/\(.*(C).*\)/'$PRI_C'\1'$'/g' |  sed 's/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g'`" | sort -k2
+		echo -e "`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1  /' | sort -k2 | sed 's/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed 's/\(.*(B).*\)/'$PRI_B'\1'$'/g' | sed 's/\(.*(C).*\)/'$PRI_C'\1'$'/g' |  sed 's/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g'`"  
 		echo "--"
-		NUMTASKS=$(wc -l "$TODO_FILE" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
+		NUMTASKS=$(cat "$TODO_FILE" | wc -l | sed 's/^[ \t]*//')
 		echo "TODO: $NUMTASKS tasks in $TODO_FILE."
 	else
-		command=`sed 's/^/ /' "$TODO_FILE" | sed 's/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed 's/\(.*(B).*\)/'$PRI_B'\1'$'/g' | sed 's/\(.*(C).*\)/'$PRI_C'\1'$'/g' | sed 's/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g' | grep -i -n $item `
+		command=`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1  /' | sort -k2 | sed 's/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed 's/\(.*(B).*\)/'$PRI_B'\1'$'/g' | sed 's/\(.*(C).*\)/'$PRI_C'\1'$'/g' |  sed 's/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g' | grep -i $item `
 		shift
 		shift
 		for i in $*
@@ -248,13 +265,13 @@
 	fi
 	cleanup ;;
 
-"listpri" )
-	pri=$2
-	if [ -z "$pri" ]; then
-		echo -e "`sed 's/^/ /' "$TODO_FILE" |  sed 's/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed 's/\(.*(B).*\)/'$PRI_B'\1'$'/g' | sed 's/\(.*(C).*\)/'$PRI_C'\1'$'/g' | sed 's/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g'`" | grep -n \([A-Z]\)  | sort -k2
-	else
-		echo -e "`sed 's/^/ /' "$TODO_FILE" |  sed 's/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed 's/\(.*(B).*\)/'$PRI_B'\1'$'/g' | sed 's/\(.*(C).*\)/'$PRI_C'\1'$'/g' | sed 's/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g'`" | grep -n \($pri\)  | sort -k2 
-	fi
+	"listpri" )
+		pri=$2
+		if [ -z "$pri" ]; then
+			echo -e "`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1  /' | sort -k2 |  sed 's/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed 's/\(.*(B).*\)/'$PRI_B'\1'$'/g' | sed 's/\(.*(C).*\)/'$PRI_C'\1'$'/g' | sed 's/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g'`" | grep \([A-Z]\)
+		else
+			echo -e "`sed = "$TODO_FILE" | sed 'N; s/^/  /; s/ *\(.\{2,\}\)\n/\1  /' | sort -k2 |  sed 's/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed 's/\(.*(B).*\)/'$PRI_B'\1'$'/g' | sed 's/\(.*(C).*\)/'$PRI_C'\1'$'/g' | sed 's/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g'`" | grep \($pri\)  
+		fi
 	cleanup;;
 "pri" )
 	item=$2
@@ -280,8 +297,8 @@
 		die "$errmsg"
 	fi;;
 "remdup" )
-	cp "$TODO_FILE" "$TMP_FILE"
-	cat "$TMP_FILE" | sed -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' > "$TODO_FILE"
+	# cp "$TODO_FILE" "$TMP_FILE"
+	sed -i.bak -n 'G; s/\n/&&/; /^\([ -~]*\n\).*\n\1/d; s/\n//; h; P' "$TODO_FILE"
 	echo "TODO: Duplicate tasks have been removed."
 	cleanup;;
 
@@ -305,11 +322,11 @@
 
 "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
+    NUMLINES=$(wc -l "$TODO_FILE" | sed 's/^[ \t]*//')
+   if [[ $NUMLINES = "0" ]]; then
          echo "datetime todos dones" >> "$REPORT_FILE"
     fi
 	#now report
