Support use of $HOME/.todo/ for all todo.sh configuration
This commit is contained in:
28
todo.sh
28
todo.sh
@@ -1,7 +1,7 @@
|
|||||||
#! /bin/bash
|
#! /bin/bash
|
||||||
|
|
||||||
# NOTE: Todo.sh requires the todo.cfg configuration file to run.
|
# NOTE: Todo.sh requires the .todo/config configuration file to run.
|
||||||
# Place the todo.cfg file in your home directory or use the -d option for a custom location.
|
# Place the .todo/config file in your home directory or use the -d option for a custom location.
|
||||||
|
|
||||||
[ -f VERSION-FILE ] && . VERSION-FILE || VERSION="@DEV_VERSION@"
|
[ -f VERSION-FILE ] && . VERSION-FILE || VERSION="@DEV_VERSION@"
|
||||||
version() { sed -e 's/^ //' <<EndVersion
|
version() { sed -e 's/^ //' <<EndVersion
|
||||||
@@ -172,7 +172,7 @@ help()
|
|||||||
Hide project names in list output. Use twice to show project
|
Hide project names in list output. Use twice to show project
|
||||||
names (default).
|
names (default).
|
||||||
-d CONFIG_FILE
|
-d CONFIG_FILE
|
||||||
Use a configuration file other than the default ~/todo.cfg
|
Use a configuration file other than the default ~/.todo/config
|
||||||
-f
|
-f
|
||||||
Forces actions without confirmation or interactive input
|
Forces actions without confirmation or interactive input
|
||||||
-h
|
-h
|
||||||
@@ -341,7 +341,7 @@ shift $(($OPTIND - 1))
|
|||||||
# defaults if not yet defined
|
# defaults if not yet defined
|
||||||
TODOTXT_VERBOSE=${TODOTXT_VERBOSE:-1}
|
TODOTXT_VERBOSE=${TODOTXT_VERBOSE:-1}
|
||||||
TODOTXT_PLAIN=${TODOTXT_PLAIN:-0}
|
TODOTXT_PLAIN=${TODOTXT_PLAIN:-0}
|
||||||
TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-$HOME/todo.cfg}
|
TODOTXT_CFG_FILE=${TODOTXT_CFG_FILE:-$HOME/.todo/config}
|
||||||
TODOTXT_FORCE=${TODOTXT_FORCE:-0}
|
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}
|
||||||
@@ -379,6 +379,15 @@ export PRI_B=$GREEN # color for B priority
|
|||||||
export PRI_C=$LIGHT_BLUE # color for C priority
|
export PRI_C=$LIGHT_BLUE # color for C priority
|
||||||
export PRI_X=$WHITE # color for rest of them
|
export PRI_X=$WHITE # color for rest of them
|
||||||
|
|
||||||
|
[ -e "$TODOTXT_CFG_FILE" ] || {
|
||||||
|
CFG_FILE_ALT="$HOME/todo.cfg"
|
||||||
|
|
||||||
|
if [ -e "$CFG_FILE_ALT" ]
|
||||||
|
then
|
||||||
|
TODOTXT_CFG_FILE="$CFG_FILE_ALT"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
[ -e "$TODOTXT_CFG_FILE" ] || {
|
[ -e "$TODOTXT_CFG_FILE" ] || {
|
||||||
CFG_FILE_ALT="$HOME/.todo.cfg"
|
CFG_FILE_ALT="$HOME/.todo.cfg"
|
||||||
|
|
||||||
@@ -390,10 +399,19 @@ export PRI_X=$WHITE # color for rest of them
|
|||||||
|
|
||||||
if [ -z "$TODO_ACTIONS_DIR" -o ! -d "$TODO_ACTIONS_DIR" ]
|
if [ -z "$TODO_ACTIONS_DIR" -o ! -d "$TODO_ACTIONS_DIR" ]
|
||||||
then
|
then
|
||||||
TODO_ACTIONS_DIR="$HOME/.todo.actions.d"
|
TODO_ACTIONS_DIR="$HOME/.todo/actions"
|
||||||
export TODO_ACTIONS_DIR
|
export TODO_ACTIONS_DIR
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
[ -d "$TODO_ACTIONS_DIR" ] || {
|
||||||
|
TODO_ACTIONS_DIR_ALT="$HOME/.todo.actions.d"
|
||||||
|
|
||||||
|
if [ -d "$TODO_ACTIONS_DIR_ALT" ]
|
||||||
|
then
|
||||||
|
TODO_ACTIONS_DIR="$TODO_ACTIONS_DIR_ALT"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# === SANITY CHECKS (thanks Karl!) ===
|
# === SANITY CHECKS (thanks Karl!) ===
|
||||||
[ -r "$TODOTXT_CFG_FILE" ] || die "Fatal error: Cannot read configuration file $TODOTXT_CFG_FILE"
|
[ -r "$TODOTXT_CFG_FILE" ] || die "Fatal error: Cannot read configuration file $TODOTXT_CFG_FILE"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user