From 42e1a658d60c96cce790d50f639397a48cc259f2 Mon Sep 17 00:00:00 2001 From: Dave Hein Date: Tue, 7 Apr 2009 09:31:06 +0800 Subject: [PATCH 01/10] Add quotes around $action to handle cases where todo.actions.d path includes embedded spaces. There were a couple places where $action was used without quotes that caused a problem if the .todo.actions.d had a parent directory path that included spaces (e.g. /cygdrive/c/Documents\ and\ Settings/jo-user). This was in the section that calls the addons with the 'usage' arg. Signed-off-by: Gina Trapani --- todo.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/todo.sh b/todo.sh index 300c640..0f45da7 100755 --- a/todo.sh +++ b/todo.sh @@ -211,9 +211,9 @@ EndHelp echo "" for action in "$TODO_ACTIONS_DIR/*" do - if [ -x $action ] + if [ -x "$action" ] then - $action usage + "$action" usage fi done echo "" From 9898e7df3f2af698c64ebf1df2d82d9a9e4fe354 Mon Sep 17 00:00:00 2001 From: Dave Hein Date: Tue, 7 Apr 2009 10:04:43 +0800 Subject: [PATCH 02/10] Fix misplaced quote that was blocking filename globbing in the action 'usage' logic. Signed-off-by: Gina Trapani --- todo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/todo.sh b/todo.sh index 0f45da7..6eab98f 100755 --- a/todo.sh +++ b/todo.sh @@ -209,7 +209,7 @@ EndHelp if [ -d "$TODO_ACTIONS_DIR" ] then echo "" - for action in "$TODO_ACTIONS_DIR/*" + for action in "$TODO_ACTIONS_DIR"/* do if [ -x "$action" ] then From 8fceae171df474b06c788f6a5881d91b8e2eeb5f Mon Sep 17 00:00:00 2001 From: Gina Trapani Date: Tue, 7 Apr 2009 10:24:06 -0700 Subject: [PATCH 03/10] Bugfix: depri no longer wipes out entire task with other parens http://tech.groups.yahoo.com/group/todotxt/message/1828 --- todo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/todo.sh b/todo.sh index 6eab98f..62f2d7f 100755 --- a/todo.sh +++ b/todo.sh @@ -633,7 +633,7 @@ case $action in if [ "$?" -eq 0 ]; then #it's all good, continue - sed -i.bak -e $2"s/^(.*) //" "$TODO_FILE" + sed -i.bak -e $2"s/^([^)]*) //" "$TODO_FILE" NEWTODO=$(sed "$2!d" "$TODO_FILE") [ $TODOTXT_VERBOSE -gt 0 ] && echo -e "`echo "$item: $NEWTODO"`" [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item deprioritized." From 3028de42a8b3252fc7178dfdc566706ccb08eb88 Mon Sep 17 00:00:00 2001 From: Gina Trapani Date: Tue, 7 Apr 2009 10:32:16 -0700 Subject: [PATCH 04/10] Bugfix, take 2: depri no longer wipes out entire task with other parens http://tech.groups.yahoo.com/group/todotxt/message/1828 --- todo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/todo.sh b/todo.sh index 62f2d7f..bfd0014 100755 --- a/todo.sh +++ b/todo.sh @@ -633,7 +633,7 @@ case $action in if [ "$?" -eq 0 ]; then #it's all good, continue - sed -i.bak -e $2"s/^([^)]*) //" "$TODO_FILE" + sed -i.bak -e $2"s/^(.) //" "$TODO_FILE" NEWTODO=$(sed "$2!d" "$TODO_FILE") [ $TODOTXT_VERBOSE -gt 0 ] && echo -e "`echo "$item: $NEWTODO"`" [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item deprioritized." From a4e68f9c3fcf093eb6748d55e174e80e9824c47a Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 8 Apr 2009 03:48:35 +0800 Subject: [PATCH 05/10] Bugfix: handling of priorities in pri/depri/do: no more globbing Signed-off-by: Gina Trapani --- todo.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/todo.sh b/todo.sh index bfd0014..843ed86 100755 --- a/todo.sh +++ b/todo.sh @@ -629,7 +629,7 @@ case $action in [ -z "$todo" ] && die "$item: No such todo." [[ "$item" = +([0-9]) ]] || die "$errmsg" - sed -e $item"s/^(.*) //" "$TODO_FILE" > /dev/null 2>&1 + sed -e $item"s/^(.) //" "$TODO_FILE" > /dev/null 2>&1 if [ "$?" -eq 0 ]; then #it's all good, continue @@ -653,7 +653,7 @@ case $action in now=`date '+%Y-%m-%d'` # remove priority once item is done - sed -i.bak $item"s/^(.*) //" "$TODO_FILE" + sed -i.bak $item"s/^(.) //" "$TODO_FILE" sed -i.bak $item"s|^|&x $now |" "$TODO_FILE" newtodo=$(sed "$item!d" "$TODO_FILE") [ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo" @@ -807,11 +807,11 @@ note: PRIORITY must be anywhere from A to Z." [[ "$item" = +([0-9]) ]] || die "$errmsg" [[ "$newpri" = +([A-Z]) ]] || die "$errmsg" - sed -e $item"s/^(.*) //" -e $item"s/^/($newpri) /" "$TODO_FILE" > /dev/null 2>&1 + sed -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE" > /dev/null 2>&1 if [ "$?" -eq 0 ]; then #it's all good, continue - sed -i.bak -e $2"s/^(.*) //" -e $2"s/^/($newpri) /" "$TODO_FILE" + sed -i.bak -e $2"s/^(.) //" -e $2"s/^/($newpri) /" "$TODO_FILE" NEWTODO=$(sed "$2!d" "$TODO_FILE") [ $TODOTXT_VERBOSE -gt 0 ] && echo -e "`echo "$item: $NEWTODO"`" [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item prioritized ($newpri)." From df1e2eb7cf7dfc1713e0de81f240421ea7915529 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 8 Apr 2009 04:00:25 +0800 Subject: [PATCH 06/10] Cleanup: del/depri/pri: some more $2 -> $item Signed-off-by: Gina Trapani --- todo.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/todo.sh b/todo.sh index 843ed86..84003f5 100755 --- a/todo.sh +++ b/todo.sh @@ -592,7 +592,7 @@ case $action in [[ "$item" = +([0-9]) ]] || die "$errmsg" if sed -ne "$item p" "$TODO_FILE" | grep "^."; then - DELETEME=$(sed "$2!d" "$TODO_FILE") + DELETEME=$(sed "$item!d" "$TODO_FILE") if [ $TODOTXT_FORCE = 0 ]; then echo "Delete '$DELETEME'? (y/n)" @@ -603,10 +603,10 @@ case $action in if [ "$ANSWER" = "y" ]; then if [ $TODOTXT_PRESERVE_LINE_NUMBERS = 0 ]; then # delete line (changes line numbers) - sed -i.bak -e $2"s/^.*//" -e '/./!d' "$TODO_FILE" + sed -i.bak -e $item"s/^.*//" -e '/./!d' "$TODO_FILE" else # leave blank line behind (preserves line numbers) - sed -i.bak -e $2"s/^.*//" "$TODO_FILE" + sed -i.bak -e $item"s/^.*//" "$TODO_FILE" fi [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: '$DELETEME' deleted." cleanup @@ -633,8 +633,8 @@ case $action in if [ "$?" -eq 0 ]; then #it's all good, continue - sed -i.bak -e $2"s/^(.) //" "$TODO_FILE" - NEWTODO=$(sed "$2!d" "$TODO_FILE") + sed -i.bak -e $item"s/^(.) //" "$TODO_FILE" + NEWTODO=$(sed "$item!d" "$TODO_FILE") [ $TODOTXT_VERBOSE -gt 0 ] && echo -e "`echo "$item: $NEWTODO"`" [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item deprioritized." cleanup @@ -811,8 +811,8 @@ note: PRIORITY must be anywhere from A to Z." if [ "$?" -eq 0 ]; then #it's all good, continue - sed -i.bak -e $2"s/^(.) //" -e $2"s/^/($newpri) /" "$TODO_FILE" - NEWTODO=$(sed "$2!d" "$TODO_FILE") + sed -i.bak -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE" + NEWTODO=$(sed "$item!d" "$TODO_FILE") [ $TODOTXT_VERBOSE -gt 0 ] && echo -e "`echo "$item: $NEWTODO"`" [ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item prioritized ($newpri)." cleanup From b9f95633dc3377ff7ac0295cfe19a349025bffe1 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Wed, 8 Apr 2009 07:16:34 +0800 Subject: [PATCH 07/10] Cleanup: removing annoying trailing space on pri tasks Signed-off-by: Gina Trapani --- todo.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/todo.sh b/todo.sh index 84003f5..253acfb 100755 --- a/todo.sh +++ b/todo.sh @@ -471,10 +471,10 @@ _list() { | ${TODOTXT_SORT_COMMAND} \ | sed ''' /^[0-9]\{'$PADDING'\} x /! { - s/\(.*(A).*\)/'$PRI_A'\1 '$DEFAULT'/g; - s/\(.*(B).*\)/'$PRI_B'\1 '$DEFAULT'/g; - s/\(.*(C).*\)/'$PRI_C'\1 '$DEFAULT'/g; - s/\(.*([D-Z]).*\)/'$PRI_X'\1 '$DEFAULT'/g; + s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g; + s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g; + s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g; + s/\(.*([D-Z]).*\)/'$PRI_X'\1'$DEFAULT'/g; } ''' \ | sed ''' From 477738828f447455e2e876508bb370ace0182169 Mon Sep 17 00:00:00 2001 From: Emil Sit Date: Sun, 5 Apr 2009 21:56:17 -0400 Subject: [PATCH 08/10] Don't set colors in default todo.cfg. Users are probably unlikely to change the definition of colors like $BLACK so just define them in todo.sh and comment them out in todo.cfg. Similarly, leave default values for priority coloring available but commented out. Signed-off-by: Emil Sit --- todo.cfg | 52 +++++++++++++++++++++++++++++----------------------- todo.sh | 30 ++++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 25 deletions(-) diff --git a/todo.cfg b/todo.cfg index cf21f79..e151213 100644 --- a/todo.cfg +++ b/todo.cfg @@ -17,30 +17,36 @@ export TMP_FILE="$TODO_DIR/todo.tmp" # === COLOR MAP === -export NONE='' -export BLACK='\\033[0;30m' -export RED='\\033[0;31m' -export GREEN='\\033[0;32m' -export BROWN='\\033[0;33m' -export BLUE='\\033[0;34m' -export PURPLE='\\033[0;35m' -export CYAN='\\033[0;36m' -export LIGHT_GREY='\\033[0;37m' -export DARK_GREY='\\033[1;30m' -export LIGHT_RED='\\033[1;31m' -export LIGHT_GREEN='\\033[1;32m' -export YELLOW='\\033[1;33m' -export LIGHT_BLUE='\\033[1;34m' -export LIGHT_PURPLE='\\033[1;35m' -export LIGHT_CYAN='\\033[1;36m' -export WHITE='\\033[1;37m' -export DEFAULT='\\033[0m' +## If you have re-mapped your color codes, you may need to +## over-ride by uncommenting and editing these defaults. + +# export BLACK='\\033[0;30m' +# export RED='\\033[0;31m' +# export GREEN='\\033[0;32m' +# export BROWN='\\033[0;33m' +# export BLUE='\\033[0;34m' +# export PURPLE='\\033[0;35m' +# export CYAN='\\033[0;36m' +# export LIGHT_GREY='\\033[0;37m' +# export DARK_GREY='\\033[1;30m' +# export LIGHT_RED='\\033[1;31m' +# export LIGHT_GREEN='\\033[1;32m' +# export YELLOW='\\033[1;33m' +# export LIGHT_BLUE='\\033[1;34m' +# export LIGHT_PURPLE='\\033[1;35m' +# export LIGHT_CYAN='\\033[1;36m' +# export WHITE='\\033[1;37m' +# export DEFAULT='\\033[0m' # === PRIORITY COLORS === -export PRI_A=$YELLOW # color for A priority -export PRI_B=$GREEN # color for B priority -export PRI_C=$LIGHT_BLUE # color for C priority -export PRI_X=$WHITE # color for rest of them +## Priorities can be any upper-case letter. +## Colors are supported for the first three. +## Uncomment and edit to override these defaults. -export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -f -k2' # customize list output \ No newline at end of file +# export PRI_A=$YELLOW # color for A priority +# export PRI_B=$GREEN # color for B priority +# export PRI_C=$LIGHT_BLUE # color for C priority +# export PRI_X=$WHITE # color for rest of them + +export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -f -k2' # customize list output diff --git a/todo.sh b/todo.sh index 253acfb..4ceeb4b 100755 --- a/todo.sh +++ b/todo.sh @@ -344,6 +344,34 @@ TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0} TODOTXT_DEFAULT_ACTION=${TODOTXT_DEFAULT_ACTION:-} TODOTXT_SORT_COMMAND=${TODOTXT_SORT_COMMAND:-env LC_COLLATE=C sort -f -k2} +export TODOTXT_VERBOSE TODOTXT_PLAIN TODOTXT_CFG_FILE TODOTXT_FORCE TODOTXT_PRESERVE_LINE_NUMBERS TODOTXT_AUTO_ARCHIVE TODOTXT_DATE_ON_ADD TODOTXT_SORT_COMMAND + +# Default color map +export NONE='' +export BLACK='\\033[0;30m' +export RED='\\033[0;31m' +export GREEN='\\033[0;32m' +export BROWN='\\033[0;33m' +export BLUE='\\033[0;34m' +export PURPLE='\\033[0;35m' +export CYAN='\\033[0;36m' +export LIGHT_GREY='\\033[0;37m' +export DARK_GREY='\\033[1;30m' +export LIGHT_RED='\\033[1;31m' +export LIGHT_GREEN='\\033[1;32m' +export YELLOW='\\033[1;33m' +export LIGHT_BLUE='\\033[1;34m' +export LIGHT_PURPLE='\\033[1;35m' +export LIGHT_CYAN='\\033[1;36m' +export WHITE='\\033[1;37m' +export DEFAULT='\\033[0m' + +# Default priority->color map. +export PRI_A=$YELLOW # color for A priority +export PRI_B=$GREEN # color for B priority +export PRI_C=$LIGHT_BLUE # color for C priority +export PRI_X=$WHITE # color for rest of them + [ -e "$TODOTXT_CFG_FILE" ] || { CFG_FILE_ALT="$HOME/.todo.cfg" @@ -353,8 +381,6 @@ TODOTXT_SORT_COMMAND=${TODOTXT_SORT_COMMAND:-env LC_COLLATE=C sort -f -k2} fi } -export TODOTXT_VERBOSE TODOTXT_PLAIN TODOTXT_CFG_FILE TODOTXT_FORCE TODOTXT_PRESERVE_LINE_NUMBERS TODOTXT_AUTO_ARCHIVE TODOTXT_DATE_ON_ADD TODOTXT_SORT_COMMAND - if [ -z "$TODO_ACTIONS_DIR" -o ! -d "$TODO_ACTIONS_DIR" ] then TODO_ACTIONS_DIR="$HOME/.todo.actions.d" From 680e93e737adbb2cdf683f2f4baa5e567f6b8cf8 Mon Sep 17 00:00:00 2001 From: Emil Sit Date: Sun, 5 Apr 2009 22:03:00 -0400 Subject: [PATCH 09/10] Don't set sort command in default todo.cfg. Instead of directly setting a value in todo.cfg, let the user know what the default is and how to customize it. This allows developers the flexibility of changing the default in todo.sh without having to worry about fixing people's config files. Signed-off-by: Emil Sit --- todo.cfg | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/todo.cfg b/todo.cfg index e151213..e41de59 100644 --- a/todo.cfg +++ b/todo.cfg @@ -49,4 +49,7 @@ export TMP_FILE="$TODO_DIR/todo.tmp" # export PRI_C=$LIGHT_BLUE # color for C priority # export PRI_X=$WHITE # color for rest of them -export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -f -k2' # customize list output +# === BEHAVIOR === + +## customize list output +# export TODOTXT_SORT_COMMAND='env LC_COLLATE=C sort -f -k2' From 4d3b7472ff02577bec24cd07ec39e7e366896ef5 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Thu, 9 Apr 2009 04:38:48 +0800 Subject: [PATCH 10/10] Bugfix: pri accepted priorities of more than a single letter e.g. todo.sh pri 1 aa Signed-off-by: Gina Trapani --- todo.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/todo.sh b/todo.sh index 4ceeb4b..347da47 100755 --- a/todo.sh +++ b/todo.sh @@ -831,7 +831,7 @@ note: PRIORITY must be anywhere from A to Z." [ "$#" -ne 3 ] && die "$errmsg" [[ "$item" = +([0-9]) ]] || die "$errmsg" - [[ "$newpri" = +([A-Z]) ]] || die "$errmsg" + [[ "$newpri" = @([A-Z]) ]] || die "$errmsg" sed -e $item"s/^(.) //" -e $item"s/^/($newpri) /" "$TODO_FILE" > /dev/null 2>&1