Add TODOTXT_UNDEF_CUSTOM_ACTIONS for recursive call of todo.sh from actions
And replace tabs by spaces.
To illustrate the interest of this new variable, here is an action
to replace the original add to allow a priority to be set when adding.
The action itself relies on the original add, therefore the need for
this new envvar.
action=$1
shift
[ "$action" = "usage" ] && {
echo " add pri PRIORITY \"THING I NEED TO DO +project @context\""
echo " add an item and prioritize it in one step"
echo ""
exit
}
. $TODOTXT_CFG_FILE
TODOTXT_UNDEF_CUSTOM_ACTIONS=1
PRIORITY=false
if [ x"$1" = x"pri" -o x"$1" = x"p" ] && [[ x"$2" =~ x[a-zA-Z] ]]; then
PRIORITY=$2
shift
shift
fi
if $TODO_SH add "$@" && [ $PRIORITY != false ]; then
# figure out the line of what we just added, and "do" it
line=`wc -l "$TODO_FILE" | cut -d' ' -f1`
$TODO_SH pri "$line" $PRIORITY
fi
This commit is contained in:
6
todo.sh
6
todo.sh
@@ -158,6 +158,7 @@ help()
|
|||||||
TODOTXT_PLAIN=1 is same as option -p
|
TODOTXT_PLAIN=1 is same as option -p
|
||||||
TODOTXT_DATE_ON_ADD=1 is same as option -t
|
TODOTXT_DATE_ON_ADD=1 is same as option -t
|
||||||
TODOTXT_VERBOSE=1 is same as option -v
|
TODOTXT_VERBOSE=1 is same as option -v
|
||||||
|
TODOTXT_UNDEF_CUSTOM_ACTIONS=1 disables .todo.actions.d
|
||||||
EndHelp
|
EndHelp
|
||||||
|
|
||||||
if [ -d "$HOME/.todo.actions.d" ]
|
if [ -d "$HOME/.todo.actions.d" ]
|
||||||
@@ -295,6 +296,7 @@ TODOTXT_FORCE=${TODOTXT_FORCE:-0}
|
|||||||
TODOTXT_PRESERVE_LINE_NUMBERS=${TODOTXT_PRESERVE_LINE_NUMBERS:-1}
|
TODOTXT_PRESERVE_LINE_NUMBERS=${TODOTXT_PRESERVE_LINE_NUMBERS:-1}
|
||||||
TODOTXT_AUTO_ARCHIVE=${TODOTXT_AUTO_ARCHIVE:-1}
|
TODOTXT_AUTO_ARCHIVE=${TODOTXT_AUTO_ARCHIVE:-1}
|
||||||
TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0}
|
TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0}
|
||||||
|
TODOTXT_UNDEF_CUSTOM_ACTIONS=${TODOTXT_UNDEF_CUSTOM_ACTIONS:-0}
|
||||||
|
|
||||||
[ -e "$TODOTXT_CFG_FILE" ] || {
|
[ -e "$TODOTXT_CFG_FILE" ] || {
|
||||||
CFG_FILE_ALT="$HOME/.todo.cfg"
|
CFG_FILE_ALT="$HOME/.todo.cfg"
|
||||||
@@ -305,7 +307,7 @@ TODOTXT_DATE_ON_ADD=${TODOTXT_DATE_ON_ADD:-0}
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
export TODOTXT_VERBOSE TODOTXT_PLAIN TODOTXT_CFG_FILE TODOTXT_FORCE TODOTXT_PRESERVE_LINE_NUMBERS TODOTXT_AUTO_ARCHIVE TODOTXT_DATE_ON_ADD
|
export TODOTXT_VERBOSE TODOTXT_PLAIN TODOTXT_CFG_FILE TODOTXT_FORCE TODOTXT_PRESERVE_LINE_NUMBERS TODOTXT_AUTO_ARCHIVE TODOTXT_DATE_ON_ADD TODOTXT_UNDEF_CUSTOM_ACTIONS
|
||||||
|
|
||||||
TODO_SH="$0"
|
TODO_SH="$0"
|
||||||
export TODO_SH
|
export TODO_SH
|
||||||
@@ -339,7 +341,7 @@ shopt -s extglob
|
|||||||
action=$( printf "%s\n" "$1" | tr 'A-Z' 'a-z' )
|
action=$( printf "%s\n" "$1" | tr 'A-Z' 'a-z' )
|
||||||
|
|
||||||
## Run and quit if there's a actions script
|
## Run and quit if there's a actions script
|
||||||
if [ -d "$HOME/.todo.actions.d" -a -x "$HOME/.todo.actions.d/$action" ]
|
if [ $TODOTXT_UNDEF_CUSTOM_ACTIONS = 0 -a -d "$HOME/.todo.actions.d" -a -x "$HOME/.todo.actions.d/$action" ]
|
||||||
then
|
then
|
||||||
"$HOME/.todo.actions.d/$action" "$@"
|
"$HOME/.todo.actions.d/$action" "$@"
|
||||||
cleanup
|
cleanup
|
||||||
|
|||||||
Reference in New Issue
Block a user