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 "$DONE_FILE" ] || cp /dev/null "$DONE_FILE"
|
||||||
[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE"
|
[ -f "$REPORT_FILE" ] || cp /dev/null "$REPORT_FILE"
|
||||||
|
|
||||||
|
|
||||||
if [ $PLAIN = 1 ]; then
|
if [ $PLAIN = 1 ]; then
|
||||||
PRI_A=$NONE
|
PRI_A=$NONE
|
||||||
PRI_B=$NONE
|
PRI_B=$NONE
|
||||||
@@ -278,16 +277,11 @@ case $action in
|
|||||||
input=$*
|
input=$*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [[ $DATE_ON_ADD = 1 ]]; then
|
if [[ $DATE_ON_ADD = 1 ]]; then
|
||||||
now=`date '+%Y-%m-%d'`
|
now=`date '+%Y-%m-%d'`
|
||||||
input="$now $input"
|
input="$now $input"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$input" >> "$TODO_FILE"
|
echo "$input" >> "$TODO_FILE"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
TASKNUM=$(wc -l "$TODO_FILE" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
|
TASKNUM=$(wc -l "$TODO_FILE" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
|
||||||
[[ $VERBOSE = 1 ]] && echo "TODO: '$input' added on line $TASKNUM."
|
[[ $VERBOSE = 1 ]] && echo "TODO: '$input' added on line $TASKNUM."
|
||||||
cleanup;;
|
cleanup;;
|
||||||
@@ -295,16 +289,13 @@ case $action in
|
|||||||
"addto" )
|
"addto" )
|
||||||
[ -z "$2" ] && die "usage: $0 addto DEST \"TODO ITEM\""
|
[ -z "$2" ] && die "usage: $0 addto DEST \"TODO ITEM\""
|
||||||
dest="$TODO_DIR/$2"
|
dest="$TODO_DIR/$2"
|
||||||
|
|
||||||
[ -z "$3" ] && die "usage: $0 addto DEST \"TODO ITEM\""
|
[ -z "$3" ] && die "usage: $0 addto DEST \"TODO ITEM\""
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
input=$*
|
input=$*
|
||||||
|
|
||||||
if [ -f "$dest" ]; then
|
if [ -f "$dest" ]; then
|
||||||
|
|
||||||
echo "$input" >> "$dest"
|
echo "$input" >> "$dest"
|
||||||
|
|
||||||
TASKNUM=$(wc -l "$dest" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
|
TASKNUM=$(wc -l "$dest" | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
|
||||||
[[ $VERBOSE = 1 ]] && echo "TODO: '$input' added to $dest on line $TASKNUM."
|
[[ $VERBOSE = 1 ]] && echo "TODO: '$input' added to $dest on line $TASKNUM."
|
||||||
else
|
else
|
||||||
@@ -318,18 +309,14 @@ case $action in
|
|||||||
|
|
||||||
[ -z "$item" ] && die "$errmsg"
|
[ -z "$item" ] && die "$errmsg"
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
|
|
||||||
|
|
||||||
if [[ -z "$1" && $FORCE = 0 ]]; then
|
if [[ -z "$1" && $FORCE = 0 ]]; then
|
||||||
echo -n "Append: "
|
echo -n "Append: "
|
||||||
read input
|
read input
|
||||||
else
|
else
|
||||||
input=$*
|
input=$*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if sed -i.bak $item" s|^.*|& $input|" "$TODO_FILE"; then
|
if sed -i.bak $item" s|^.*|& $input|" "$TODO_FILE"; then
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[[ $VERBOSE = 1 ]] && echo "$item: $newtodo"
|
[[ $VERBOSE = 1 ]] && echo "$item: $newtodo"
|
||||||
@@ -359,7 +346,6 @@ case $action in
|
|||||||
else
|
else
|
||||||
ANSWER="y"
|
ANSWER="y"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ANSWER" = "y" ]; then
|
if [ "$ANSWER" = "y" ]; then
|
||||||
if [ $PRESERVE_LINE_NUMBERS = 0 ]; then
|
if [ $PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||||
# delete line (changes line numbers)
|
# delete line (changes line numbers)
|
||||||
@@ -370,7 +356,6 @@ case $action in
|
|||||||
fi
|
fi
|
||||||
[[ $VERBOSE = 1 ]] && echo "TODO: '$DELETEME' deleted."
|
[[ $VERBOSE = 1 ]] && echo "TODO: '$DELETEME' deleted."
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "TODO: No tasks were deleted."
|
echo "TODO: No tasks were deleted."
|
||||||
fi
|
fi
|
||||||
@@ -423,7 +408,6 @@ case $action in
|
|||||||
if [ $AUTO_ARCHIVE = 1 ]; then
|
if [ $AUTO_ARCHIVE = 1 ]; then
|
||||||
archive
|
archive
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cleanup ;;
|
cleanup ;;
|
||||||
|
|
||||||
|
|
||||||
@@ -443,10 +427,8 @@ case $action in
|
|||||||
command=`echo "$command" | grep -i $i `
|
command=`echo "$command" | grep -i $i `
|
||||||
done
|
done
|
||||||
command=`echo "$command" | sort -f -k2`
|
command=`echo "$command" | sort -f -k2`
|
||||||
|
|
||||||
echo -e "$command"
|
echo -e "$command"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cleanup ;;
|
cleanup ;;
|
||||||
|
|
||||||
"listall" | "lsa" )
|
"listall" | "lsa" )
|
||||||
@@ -464,7 +446,6 @@ case $action in
|
|||||||
command=`echo "$command" | grep -i $i `
|
command=`echo "$command" | grep -i $i `
|
||||||
done
|
done
|
||||||
command=`echo "$command" | sort -f -k2`
|
command=`echo "$command" | sort -f -k2`
|
||||||
|
|
||||||
echo -e "$command"
|
echo -e "$command"
|
||||||
fi
|
fi
|
||||||
cleanup ;;
|
cleanup ;;
|
||||||
@@ -478,7 +459,6 @@ case $action in
|
|||||||
else
|
else
|
||||||
item=$3
|
item=$3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$src" ]; then
|
if [ -f "$src" ]; then
|
||||||
if [ -z "$item" ]; 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'/'`"
|
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 `
|
command=`echo "$command" | grep -i $i `
|
||||||
done
|
done
|
||||||
command=`echo "$command" | sort -f -k2`
|
command=`echo "$command" | sort -f -k2`
|
||||||
|
|
||||||
echo -e "$command"
|
echo -e "$command"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "TODO: File $src does not exist."
|
echo "TODO: File $src does not exist."
|
||||||
|
|
||||||
fi
|
fi
|
||||||
cleanup ;;
|
cleanup ;;
|
||||||
|
|
||||||
@@ -516,7 +494,6 @@ case $action in
|
|||||||
|
|
||||||
"listpri" | "lsp" )
|
"listpri" | "lsp" )
|
||||||
pri=$( printf "%s\n" "$2" | tr 'a-z' 'A-Z' )
|
pri=$( printf "%s\n" "$2" | tr 'a-z' 'A-Z' )
|
||||||
|
|
||||||
errmsg="usage: $0 listpri PRIORITY
|
errmsg="usage: $0 listpri PRIORITY
|
||||||
note: PRIORITY must a single letter from A to Z."
|
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/')
|
NUMTASKS=$(grep \($pri\) "$TODO_FILE" | wc -l | sed 's/^[[:space:]]*\([0-9]*\).*/\1/')
|
||||||
echo "TODO: $NUMTASKS tasks prioritized $pri in $TODO_FILE."
|
echo "TODO: $NUMTASKS tasks prioritized $pri in $TODO_FILE."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fi
|
fi
|
||||||
cleanup;;
|
cleanup;;
|
||||||
|
|
||||||
"move" | "mv" )
|
"move" | "mv" )
|
||||||
|
|
||||||
# replace moved line with a blank line when PRESERVE_LINE_NUMBERS is 1
|
# replace moved line with a blank line when PRESERVE_LINE_NUMBERS is 1
|
||||||
errmsg="usage: $0 mv ITEM# DEST [SRC]"
|
errmsg="usage: $0 mv ITEM# DEST [SRC]"
|
||||||
|
|
||||||
item=$2
|
item=$2
|
||||||
dest="$TODO_DIR/$3"
|
dest="$TODO_DIR/$3"
|
||||||
|
|
||||||
src="$TODO_DIR/$4"
|
src="$TODO_DIR/$4"
|
||||||
|
|
||||||
[ -z "$item" ] && die "$errmsg"
|
[ -z "$item" ] && die "$errmsg"
|
||||||
|
|
||||||
[ -z "$4" ] && src="$TODO_FILE"
|
[ -z "$4" ] && src="$TODO_FILE"
|
||||||
[ -z "$dest" ] && die "$errmsg"
|
[ -z "$dest" ] && die "$errmsg"
|
||||||
|
|
||||||
@@ -559,17 +531,14 @@ note: PRIORITY must a single letter from A to Z."
|
|||||||
|
|
||||||
if [ -f "$src" ]; then
|
if [ -f "$src" ]; then
|
||||||
if [ -f "$dest" ]; then
|
if [ -f "$dest" ]; then
|
||||||
|
|
||||||
if sed -ne "$item p" "$src" | grep "^."; then
|
if sed -ne "$item p" "$src" | grep "^."; then
|
||||||
MOVEME=$(sed "$item!d" "$src")
|
MOVEME=$(sed "$item!d" "$src")
|
||||||
|
|
||||||
if [ $FORCE = 0 ]; then
|
if [ $FORCE = 0 ]; then
|
||||||
echo "Move '$MOVEME' from $src to $dest? (y/n)"
|
echo "Move '$MOVEME' from $src to $dest? (y/n)"
|
||||||
read ANSWER
|
read ANSWER
|
||||||
else
|
else
|
||||||
ANSWER="y"
|
ANSWER="y"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$ANSWER" = "y" ]; then
|
if [ "$ANSWER" = "y" ]; then
|
||||||
if [ $PRESERVE_LINE_NUMBERS = 0 ]; then
|
if [ $PRESERVE_LINE_NUMBERS = 0 ]; then
|
||||||
# delete line (changes line numbers)
|
# 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'."
|
[[ $VERBOSE = 1 ]] && echo "TODO: '$MOVEME' moved from '$src' to '$dest'."
|
||||||
cleanup
|
cleanup
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "TODO: No tasks moved."
|
echo "TODO: No tasks moved."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "$item: No such item in $src."
|
echo "$item: No such item in $src."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
echo "TODO: Destination file $dest does not exist."
|
echo "TODO: Destination file $dest does not exist."
|
||||||
fi
|
fi
|
||||||
@@ -605,7 +572,6 @@ note: PRIORITY must a single letter from A to Z."
|
|||||||
[ -z "$item" ] && die "$errmsg"
|
[ -z "$item" ] && die "$errmsg"
|
||||||
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
[[ "$item" = +([0-9]) ]] || die "$errmsg"
|
||||||
|
|
||||||
|
|
||||||
todo=$(sed "$item!d" "$TODO_FILE")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -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")
|
todo=$(sed "$item!d" "$TODO_FILE")
|
||||||
[ -z "$todo" ] && die "$item: No such todo."
|
[ -z "$todo" ] && die "$item: No such todo."
|
||||||
|
|
||||||
|
|
||||||
if [[ -z "$1" && $FORCE = 0 ]]; then
|
if [[ -z "$1" && $FORCE = 0 ]]; then
|
||||||
echo -n "Replacement: "
|
echo -n "Replacement: "
|
||||||
read input
|
read input
|
||||||
@@ -690,12 +655,11 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
[[ $VERBOSE = 1 ]] && echo "TODO: Report file updated."
|
[[ $VERBOSE = 1 ]] && echo "TODO: Report file updated."
|
||||||
cat "$REPORT_FILE"
|
cat "$REPORT_FILE"
|
||||||
cleanup;;
|
cleanup;;
|
||||||
|
|
||||||
* )
|
* )
|
||||||
usage
|
usage
|
||||||
if [ -d "$HOME/.todo.actions.d" ]
|
if [ -d "$HOME/.todo.actions.d" ]; then
|
||||||
then
|
if [ -x "$HOME/.todo.actions.d/$action" ]; then
|
||||||
if [ -x "$HOME/.todo.actions.d/$action" ]
|
|
||||||
then
|
|
||||||
CFG_FILE="$CFG_FILE" "$HOME/.todo.actions.d/$action" "$@"
|
CFG_FILE="$CFG_FILE" "$HOME/.todo.actions.d/$action" "$@"
|
||||||
else
|
else
|
||||||
usage
|
usage
|
||||||
|
|||||||
Reference in New Issue
Block a user