From 6bc05000d9013e54a7a650e159274d85209f2d97 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 11 Mar 2009 10:50:14 -0700 Subject: [PATCH 1/3] Add TODOTXT_DEFAULT_ACTION variable. I like to set this to "ls" so I can just run "todo.sh" (or "t") to list my tasks. --- todo.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/todo.sh b/todo.sh index da1db3b..ef732e9 100755 --- a/todo.sh +++ b/todo.sh @@ -149,6 +149,7 @@ help() TODOTXT_PLAIN=1 is same as option -p TODOTXT_DATE_ON_ADD=1 is same as option -t TODOTXT_VERBOSE=1 is same as option -v + TODOTXT_DEFAULT_ACTION="" run this when called with no arguments EndHelp if [ -d "$HOME/.todo.actions.d" ] @@ -238,6 +239,7 @@ TODOTXT_FORCE=${TODOTXT_FORCE:-0} TODOTXT_PRESERVE_LINE_NUMBERS=${TODOTXT_PRESERVE_LINE_NUMBERS:-1} TODOTXT_AUTO_ARCHIVE=${TODOTXT_AUTO_ARCHIVE:-1} TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0} +TODOTXT_DEFAULT_ACTION=${TODOTXT_DEFAULT_ACTION:-} [ -e "$TODOTXT_CFG_FILE" ] || { CFG_FILE_ALT="$HOME/.todo.cfg" @@ -258,7 +260,9 @@ export TODO_SH . "$TODOTXT_CFG_FILE" -[ -z "$1" ] && usage +ACTION=${1:-$TODOTXT_DEFAULT_ACTION} + +[ -z "$ACTION" ] && 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" @@ -279,7 +283,7 @@ fi shopt -s extglob # == HANDLE ACTION == -action=$( printf "%s\n" "$1" | tr 'A-Z' 'a-z' ) +action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' ) case $action in "add" | "a") From 3e9d40ebd71cba61f3217a86333ae2412eeadea6 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Wed, 11 Mar 2009 11:36:23 -0700 Subject: [PATCH 2/3] 'edit' plugin to open files in a text editor. --- todo.actions.d/edit | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 todo.actions.d/edit diff --git a/todo.actions.d/edit b/todo.actions.d/edit new file mode 100755 index 0000000..f13ba19 --- /dev/null +++ b/todo.actions.d/edit @@ -0,0 +1,12 @@ +#!/bin/bash +case $1 in +"usage") + echo "$(basename $0) [BASENAME]" + echo " Open \$TODO_DIR/BASENAME.txt in \$EDITOR." + echo " If BASENAME is not given, defaults to 'todo'." + ;; +*) + FILE=${2:-todo}.txt + $EDITOR $TODO_DIR/$FILE + ;; +esac From 3df7497287e5b3c816624ad57517cf26120580e9 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Thu, 12 Mar 2009 01:50:14 +0800 Subject: [PATCH 3/3] Add TODOTXT_DEFAULT_ACTION variable. I like to set this to "ls" so I can just run "todo.sh" (or "t") to list my tasks. Signed-off-by: Gina Trapani --- todo.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/todo.sh b/todo.sh index 67c3c75..9c6923a 100755 --- a/todo.sh +++ b/todo.sh @@ -162,6 +162,7 @@ help() TODOTXT_PLAIN=1 is same as option -p TODOTXT_DATE_ON_ADD=1 is same as option -t TODOTXT_VERBOSE=1 is same as option -v + TODOTXT_DEFAULT_ACTION="" run this when called with no arguments EndHelp if [ -d "$HOME/.todo.actions.d" ] @@ -299,6 +300,7 @@ TODOTXT_FORCE=${TODOTXT_FORCE:-0} TODOTXT_PRESERVE_LINE_NUMBERS=${TODOTXT_PRESERVE_LINE_NUMBERS:-1} TODOTXT_AUTO_ARCHIVE=${TODOTXT_AUTO_ARCHIVE:-1} TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0} +TODOTXT_DEFAULT_ACTION=${TODOTXT_DEFAULT_ACTION:-} [ -e "$TODOTXT_CFG_FILE" ] || { CFG_FILE_ALT="$HOME/.todo.cfg" @@ -319,7 +321,9 @@ export TODO_SH . "$TODOTXT_CFG_FILE" -[ -z "$1" ] && usage +ACTION=${1:-$TODOTXT_DEFAULT_ACTION} + +[ -z "$ACTION" ] && 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" @@ -340,7 +344,7 @@ fi shopt -s extglob # == HANDLE ACTION == -action=$( printf "%s\n" "$1" | tr 'A-Z' 'a-z' ) +action=$( printf "%s\n" "$ACTION" | tr 'A-Z' 'a-z' ) ## If the first argument is "command", run the rest of the arguments ## using todo.sh builtins.