Run .todo.actions.d Before Builtins
. Let users override default commands by creating a script in ~/.todo.actions.d/ with the same name as a default command. Idea by Don Harper and David A. Harding; patch by Harding. . The patch adds the following logic and increases the indent level for the case statement: . +if [ -d "$HOME/.todo.actions.d" -a -x "$HOME/.todo.actions.d/$action" ] +then + CFG_FILE="$CFG_FILE" "$HOME/.todo.actions.d/$action" "$@" +else + case $action in
This commit is contained in:
15
todo.sh
15
todo.sh
@@ -332,6 +332,10 @@ shopt -s extglob
|
||||
# == HANDLE ACTION ==
|
||||
action=$( printf "%s\n" "$1" | tr 'A-Z' 'a-z' )
|
||||
|
||||
if [ -d "$HOME/.todo.actions.d" -a -x "$HOME/.todo.actions.d/$action" ]
|
||||
then
|
||||
CFG_FILE="$CFG_FILE" "$HOME/.todo.actions.d/$action" "$@"
|
||||
else
|
||||
case $action in
|
||||
"add" | "a")
|
||||
if [[ -z "$2" && $FORCE = 0 ]]; then
|
||||
@@ -744,13 +748,6 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
|
||||
* )
|
||||
usage
|
||||
if [ -d "$HOME/.todo.actions.d" ]; then
|
||||
if [ -x "$HOME/.todo.actions.d/$action" ]; then
|
||||
CFG_FILE="$CFG_FILE" "$HOME/.todo.actions.d/$action" "$@"
|
||||
else
|
||||
usage
|
||||
fi
|
||||
else
|
||||
usage
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user