Don't Echo Empty Lines & Streamline Sed wc -l Syntax
This commit is contained in:
16
todo.sh
16
todo.sh
@@ -392,7 +392,7 @@ _list() {
|
|||||||
|
|
||||||
## Figure out how much padding we need to use
|
## Figure out how much padding we need to use
|
||||||
## We need one level of padding for each power of 10 $LINES uses
|
## We need one level of padding for each power of 10 $LINES uses
|
||||||
LINES=$( sed -ne '$ =' < "$src" )
|
LINES=$( sed -n '$ =' "$src" )
|
||||||
PADDING=${#LINES}
|
PADDING=${#LINES}
|
||||||
|
|
||||||
## Number, sort, and mangle the file, then run the filter command,
|
## Number, sort, and mangle the file, then run the filter command,
|
||||||
@@ -424,10 +424,10 @@ _list() {
|
|||||||
s/'${HIDE_CONTEXTS_SUBSTITUTION:-^}'//g
|
s/'${HIDE_CONTEXTS_SUBSTITUTION:-^}'//g
|
||||||
''' \
|
''' \
|
||||||
)
|
)
|
||||||
echo -e "$command"
|
echo -ne "$command${command:+\n}"
|
||||||
|
|
||||||
if [ $TODOTXT_VERBOSE == 1 ]; then
|
if [ $TODOTXT_VERBOSE == 1 ]; then
|
||||||
NUMTASKS=$( echo -e "$command" | sed -ne '/^$/d' -e '$ =' )
|
NUMTASKS=$( echo -ne "$command" | sed -n '$ =' )
|
||||||
|
|
||||||
echo "--"
|
echo "--"
|
||||||
echo "TODO: ${NUMTASKS:-0} of $LINES tasks shown from $FILE"
|
echo "TODO: ${NUMTASKS:-0} of $LINES tasks shown from $FILE"
|
||||||
@@ -472,7 +472,7 @@ case $action in
|
|||||||
input="$now $input"
|
input="$now $input"
|
||||||
fi
|
fi
|
||||||
echo "$input" >> "$TODO_FILE"
|
echo "$input" >> "$TODO_FILE"
|
||||||
TASKNUM=$(sed -ne "$ =" < "$TODO_FILE")
|
TASKNUM=$(sed -n '$ =' "$TODO_FILE")
|
||||||
[[ $TODOTXT_VERBOSE = 1 ]] && echo "TODO: '$input' added on line $TASKNUM."
|
[[ $TODOTXT_VERBOSE = 1 ]] && echo "TODO: '$input' added on line $TASKNUM."
|
||||||
cleanup;;
|
cleanup;;
|
||||||
|
|
||||||
@@ -486,7 +486,7 @@ case $action in
|
|||||||
|
|
||||||
if [ -f "$dest" ]; then
|
if [ -f "$dest" ]; then
|
||||||
echo "$input" >> "$dest"
|
echo "$input" >> "$dest"
|
||||||
TASKNUM=$(sed -ne "$ =" < "$dest")
|
TASKNUM=$(sed -n '$ =' "$dest")
|
||||||
[[ $TODOTXT_VERBOSE = 1 ]] && echo "TODO: '$input' added to $dest on line $TASKNUM."
|
[[ $TODOTXT_VERBOSE = 1 ]] && echo "TODO: '$input' added to $dest on line $TASKNUM."
|
||||||
else
|
else
|
||||||
echo "TODO: Destination file $dest does not exist."
|
echo "TODO: Destination file $dest does not exist."
|
||||||
@@ -782,13 +782,13 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
sed '/^x /!d' "$TODO_FILE" >> "$DONE_FILE"
|
sed '/^x /!d' "$TODO_FILE" >> "$DONE_FILE"
|
||||||
sed -i.bak '/^x /d' "$TODO_FILE"
|
sed -i.bak '/^x /d' "$TODO_FILE"
|
||||||
|
|
||||||
NUMLINES=$( sed -ne '$ =' < "$TODO_FILE" )
|
NUMLINES=$( sed -n '$ =' "$TODO_FILE" )
|
||||||
if [ ${NUMLINES:-0} = "0" ]; then
|
if [ ${NUMLINES:-0} = "0" ]; then
|
||||||
echo "datetime todos dones" >> "$REPORT_FILE"
|
echo "datetime todos dones" >> "$REPORT_FILE"
|
||||||
fi
|
fi
|
||||||
#now report
|
#now report
|
||||||
TOTAL=$( sed -ne '$ =' < "$TODO_FILE" )
|
TOTAL=$( sed -n '$ =' "$TODO_FILE" )
|
||||||
TDONE=$( sed -ne '$ =' < "$DONE_FILE" )
|
TDONE=$( sed -n '$ =' "$DONE_FILE" )
|
||||||
TECHO=$(echo $(date +%Y-%m-%d-%T); echo ' '; echo ${TOTAL:-0}; echo ' ';
|
TECHO=$(echo $(date +%Y-%m-%d-%T); echo ' '; echo ${TOTAL:-0}; echo ' ';
|
||||||
echo ${TDONE:-0})
|
echo ${TDONE:-0})
|
||||||
echo $TECHO >> "$REPORT_FILE"
|
echo $TECHO >> "$REPORT_FILE"
|
||||||
|
|||||||
Reference in New Issue
Block a user