Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2a65615c7a | ||
|
|
d7e194b09d | ||
|
|
a4ab8a808a |
@@ -71,6 +71,11 @@ TODO: 4 prioritized (A).
|
|||||||
4: (A) collect the eggs
|
4: (A) collect the eggs
|
||||||
replaced with
|
replaced with
|
||||||
4: (A) collect the bread
|
4: (A) collect the bread
|
||||||
|
|
||||||
|
>>> todo.sh replace 4 collect the eggs
|
||||||
|
4: (A) collect the bread
|
||||||
|
replaced with
|
||||||
|
4: (A) collect the eggs
|
||||||
EOF
|
EOF
|
||||||
test_todo_session 'replace with &' << EOF
|
test_todo_session 'replace with &' << EOF
|
||||||
>>> todo.sh replace 3 "thrash the hay & thresh the wheat"
|
>>> todo.sh replace 3 "thrash the hay & thresh the wheat"
|
||||||
|
|||||||
40
todo.sh
40
todo.sh
@@ -262,7 +262,7 @@ cleaninput()
|
|||||||
action_regexp="^\(append\|app\|prepend\|prep\|replace\)$"
|
action_regexp="^\(append\|app\|prepend\|prep\|replace\)$"
|
||||||
|
|
||||||
# Check which action we are being used in as this affects what cleaning we do
|
# Check which action we are being used in as this affects what cleaning we do
|
||||||
if [ `echo $action | grep -c $action_regexp` -eq 1 ]; then
|
if [ `echo $action | grep -c $action_regexp` -eq 1 ]; then
|
||||||
# These actions use sed and & as the matched string so escape it
|
# These actions use sed and & as the matched string so escape it
|
||||||
input=`echo $input | sed 's/\&/\\\&/g'`
|
input=`echo $input | sed 's/\&/\\\&/g'`
|
||||||
fi
|
fi
|
||||||
@@ -772,26 +772,26 @@ case $action in
|
|||||||
# Split multiple do's, if comma seperated change to whitespace sepereated
|
# Split multiple do's, if comma seperated change to whitespace sepereated
|
||||||
# Loop the 'do' function for each item
|
# Loop the 'do' function for each item
|
||||||
for item in `echo $* | tr ',' ' '`; do
|
for item in `echo $* | tr ',' ' '`; do
|
||||||
[ -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."
|
||||||
|
|
||||||
# Check if this item has already been done
|
# Check if this item has already been done
|
||||||
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
|
if [ `echo $todo | grep -c "^x "` -eq 0 ] ; then
|
||||||
now=`date '+%Y-%m-%d'`
|
now=`date '+%Y-%m-%d'`
|
||||||
# remove priority once item is done
|
# remove priority once item is done
|
||||||
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
|
sed -i.bak $item"s/^(.) //" "$TODO_FILE"
|
||||||
sed -i.bak $item"s|^|&x $now |" "$TODO_FILE"
|
sed -i.bak $item"s|^|&x $now |" "$TODO_FILE"
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
newtodo=$(sed "$item!d" "$TODO_FILE")
|
newtodo=$(sed "$item!d" "$TODO_FILE")
|
||||||
echo "$item: $newtodo"
|
echo "$item: $newtodo"
|
||||||
echo "TODO: $item marked as done."
|
echo "TODO: $item marked as done."
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
echo "$item is already marked done"
|
echo "$item is already marked done"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
|
if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
|
||||||
@@ -1011,7 +1011,7 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
if [ -z $priority ]; then
|
if [ -z $priority ]; then
|
||||||
sed -i.bak $item" s|^.*|$input|" "$TODO_FILE"
|
sed -i.bak $item" s|^.*|$input|" "$TODO_FILE"
|
||||||
else
|
else
|
||||||
sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $1|" "$TODO_FILE"
|
sed -i.bak -e "$item s/^(.) //" -e "$item s|^.*|\($priority\) $input|" "$TODO_FILE"
|
||||||
fi
|
fi
|
||||||
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
[ $TODOTXT_VERBOSE -gt 0 ] && {
|
||||||
NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
|
NEWTODO=$(head -$item "$TODO_FILE" | tail -1)
|
||||||
|
|||||||
Reference in New Issue
Block a user