Cleaning indentation and mix of tabs/spaces, nothing else I swear ;-)
Signed-off-by: ginatrapani <ginatrapani@gmail.com>
This commit is contained in:
committed by
ginatrapani
parent
25c6505007
commit
586abe8282
42
todo.sh
42
todo.sh
@@ -252,7 +252,6 @@ echo '' > "$TMP_FILE" || die "Fatal Error: Unable to write in $TODO_DIR"
|
||||
[ -f "$DONE_FILE" ] || cp /dev/null "$DONE_FILE"
|
||||
[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE"
|
||||
|
||||
|
||||
if [ $PLAIN = 1 ]; then
|
||||
PRI_A=$NONE
|
||||
PRI_B=$NONE
|
||||
@@ -278,16 +277,11 @@ case $action in
|
||||
input=$*
|
||||
fi
|
||||
|
||||
|
||||
if [[ $DATE_ON_ADD = 1 ]]; then
|
||||
now=`date '+%Y-%m-%d'`
|
||||
input="$now $input"
|
||||
fi
|
||||
|
||||
echo "$input" >> "$TODO_FILE"
|
||||
|
||||
|
||||
|
||||
TASKNUM=$(wc -l "$TODO_FILE" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
|
||||
[[ $VERBOSE = 1 ]] && echo "TODO: '$input' added on line $TASKNUM."
|
||||
cleanup;;
|
||||
@@ -295,16 +289,13 @@ case $action in
|
||||
"addto" )
|
||||
[ -z "$2" ] && die "usage: $0 addto DEST \"TODO ITEM\""
|
||||
dest="$TODO_DIR/$2"
|
||||
|
||||
[ -z "$3" ] && die "usage: $0 addto DEST \"TODO ITEM\""
|
||||
shift
|
||||
shift
|
||||
input=$*
|
||||
|
||||
if [ -f "$dest" ]; then
|
||||
|
||||
echo "$input" >> "$dest"
|
||||
|
||||
TASKNUM=$(wc -l "$dest" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
|
||||
[[ $VERBOSE = 1 ]] && echo "TODO: '$input' added to $dest on line $TASKNUM."
|
||||
else
|
||||
@@ -318,18 +309,14 @@ case $action in
|
||||
|
||||
[ -z "$item" ] && die "$errmsg"
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
|
||||
todo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ -z "$todo" ] && die "$item: No such todo."
|
||||
|
||||
|
||||
if [[ -z "$1" && $FORCE = 0 ]]; then
|
||||
echo -n "Append: "
|
||||
read input
|
||||
else
|
||||
input=$*
|
||||
fi
|
||||
|
||||
if sed -i.bak $item" s|^.*|& $input|" "$TODO_FILE"; then
|
||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||
[[ $VERBOSE = 1 ]] && echo "$item: $newtodo"
|
||||
@@ -359,7 +346,6 @@ case $action in
|
||||
else
|
||||
ANSWER="y"
|
||||
fi
|
||||
|
||||
if [ "$ANSWER" = "y" ]; then
|
||||
if [ $PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||
# delete line (changes line numbers)
|
||||
@@ -370,7 +356,6 @@ case $action in
|
||||
fi
|
||||
[[ $VERBOSE = 1 ]] && echo "TODO: '$DELETEME' deleted."
|
||||
cleanup
|
||||
|
||||
else
|
||||
echo "TODO: No tasks were deleted."
|
||||
fi
|
||||
@@ -423,7 +408,6 @@ case $action in
|
||||
if [ $AUTO_ARCHIVE = 1 ]; then
|
||||
archive
|
||||
fi
|
||||
|
||||
cleanup ;;
|
||||
|
||||
|
||||
@@ -443,10 +427,8 @@ case $action in
|
||||
command=`echo "$command" | grep -i $i `
|
||||
done
|
||||
command=`echo "$command" | sort -f -k2`
|
||||
|
||||
echo -e "$command"
|
||||
fi
|
||||
|
||||
cleanup ;;
|
||||
|
||||
"listall" | "lsa" )
|
||||
@@ -464,7 +446,6 @@ case $action in
|
||||
command=`echo "$command" | grep -i $i `
|
||||
done
|
||||
command=`echo "$command" | sort -f -k2`
|
||||
|
||||
echo -e "$command"
|
||||
fi
|
||||
cleanup ;;
|
||||
@@ -478,7 +459,6 @@ case $action in
|
||||
else
|
||||
item=$3
|
||||
fi
|
||||
|
||||
if [ -f "$src" ]; then
|
||||
if [ -z "$item" ]; then
|
||||
echo -e "`sed = "$src" | sed 'N; s/^/ /; s/ *\(.\{2,\}\)\n/\1 /' | sed 's/^ /0/' | sort -f -k2 | sed '/^[0-9][0-9] x /!s/\(.*(A).*\)/'$PRI_A'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(B).*\)/'$PRI_B'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*(C).*\)/'$PRI_C'\1'$DEFAULT'/g' | sed '/^[0-9][0-9] x /!s/\(.*([A-Z]).*\)/'$PRI_X'\1'$DEFAULT'/'`"
|
||||
@@ -496,12 +476,10 @@ case $action in
|
||||
command=`echo "$command" | grep -i $i `
|
||||
done
|
||||
command=`echo "$command" | sort -f -k2`
|
||||
|
||||
echo -e "$command"
|
||||
fi
|
||||
else
|
||||
echo "TODO: File $src does not exist."
|
||||
|
||||
fi
|
||||
cleanup ;;
|
||||
|
||||
@@ -516,7 +494,6 @@ case $action in
|
||||
|
||||
"listpri" | "lsp" )
|
||||
pri=$( printf "%s\n" "$2" | tr 'a-z' 'A-Z' )
|
||||
|
||||
errmsg="usage: $0 listpri PRIORITY
|
||||
note: PRIORITY must a single letter from A to Z."
|
||||
|
||||
@@ -536,22 +513,17 @@ note: PRIORITY must a single letter from A to Z."
|
||||
NUMTASKS=$(grep \($pri\) "$TODO_FILE" | wc -l | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
|
||||
echo "TODO: $NUMTASKS tasks prioritized $pri in $TODO_FILE."
|
||||
fi
|
||||
|
||||
fi
|
||||
cleanup;;
|
||||
|
||||
"move" | "mv" )
|
||||
|
||||
# replace moved line with a blank line when PRESERVE_LINE_NUMBERS is 1
|
||||
errmsg="usage: $0 mv ITEM# DEST [SRC]"
|
||||
|
||||
item=$2
|
||||
dest="$TODO_DIR/$3"
|
||||
|
||||
src="$TODO_DIR/$4"
|
||||
|
||||
[ -z "$item" ] && die "$errmsg"
|
||||
|
||||
[ -z "$4" ] && src="$TODO_FILE"
|
||||
[ -z "$dest" ] && die "$errmsg"
|
||||
|
||||
@@ -559,17 +531,14 @@ note: PRIORITY must a single letter from A to Z."
|
||||
|
||||
if [ -f "$src" ]; then
|
||||
if [ -f "$dest" ]; then
|
||||
|
||||
if sed -ne "$item p" "$src" | grep "^."; then
|
||||
MOVEME=$(sed "$item!d" "$src")
|
||||
|
||||
if [ $FORCE = 0 ]; then
|
||||
echo "Move '$MOVEME' from $src to $dest? (y/n)"
|
||||
read ANSWER
|
||||
else
|
||||
ANSWER="y"
|
||||
fi
|
||||
|
||||
if [ "$ANSWER" = "y" ]; then
|
||||
if [ $PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||
# delete line (changes line numbers)
|
||||
@@ -582,14 +551,12 @@ note: PRIORITY must a single letter from A to Z."
|
||||
|
||||
[[ $VERBOSE = 1 ]] && echo "TODO: '$MOVEME' moved from '$src' to '$dest'."
|
||||
cleanup
|
||||
|
||||
else
|
||||
echo "TODO: No tasks moved."
|
||||
fi
|
||||
else
|
||||
echo "$item: No such item in $src."
|
||||
fi
|
||||
|
||||
else
|
||||
echo "TODO: Destination file $dest does not exist."
|
||||
fi
|
||||
@@ -605,7 +572,6 @@ note: PRIORITY must a single letter from A to Z."
|
||||
[ -z "$item" ] && die "$errmsg"
|
||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||
|
||||
|
||||
todo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ -z "$todo" ] && die "$item: No such todo."
|
||||
|
||||
@@ -658,7 +624,6 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
todo=$(sed "$item!d" "$TODO_FILE")
|
||||
[ -z "$todo" ] && die "$item: No such todo."
|
||||
|
||||
|
||||
if [[ -z "$1" && $FORCE = 0 ]]; then
|
||||
echo -n "Replacement: "
|
||||
read input
|
||||
@@ -690,12 +655,11 @@ note: PRIORITY must be anywhere from A to Z."
|
||||
[[ $VERBOSE = 1 ]] && echo "TODO: Report file updated."
|
||||
cat "$REPORT_FILE"
|
||||
cleanup;;
|
||||
|
||||
* )
|
||||
usage
|
||||
if [ -d "$HOME/.todo.actions.d" ]
|
||||
then
|
||||
if [ -x "$HOME/.todo.actions.d/$action" ]
|
||||
then
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user