-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdf
executable file
·67 lines (56 loc) · 1.7 KB
/
df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
#
# Like 'do' only you specify a file as well as a number
# Compliments "addto" and "mv"
#
# Author: Jon Smajda
# License: GPL, http://www.gnu.org/copyleft/gpl.html
# URL: http://github.com/smajda/todo.actions.d
action=$1
shift
# what to display in todo.sh -h, appended to very end
[ "$action" = "usage" ] && {
echo " `basename $0` SRC NUMBER"
echo " In file, SRC, mark item on line NUMBER as done."
echo " Note: Doesn't work with auto-archiving on."
echo " See $0"
echo ""
exit
}
### define error messages and variables for df
errmsg="usage: $0 df SRC ITEM#"
TODO_FILE=$TODO_DIR/$1
item=$2
# check to see if todo file at $1 is valid:
if [ ! -f "$TODO_FILE" ]; then
echo "File $TODO_FILE does not exist"
echo "$errmsg"
exit
fi
# make sure an item# is specified
# -eq trick to see if it's a number
if [ "$item" -eq "$item" 2> /dev/null ]; then
continue
else
echo "$item" is NOT a valid number
echo "$errmsg"
exit
fi
# now just copy the rest of the code from regular TODO
todo=$(sed "$item!d" "$TODO_FILE")
[ -z "$todo" ] && die "$item: No such todo."
now=`date '+%Y-%m-%d'`
# remove priority once item is done
sed -i.bak $item"s/^(.*) //" "$TODO_FILE"
sed -i.bak $item"s|^|&x $now |" "$TODO_FILE"
newtodo=$(sed "$item!d" "$TODO_FILE")
[ $TODOTXT_VERBOSE -gt 0 ] && echo "$item: $newtodo"
[ $TODOTXT_VERBOSE -gt 0 ] && echo "TODO: $item marked as done."
# Archive doesn't work b/c todo.sh
# doesn't export archive and cleanup functions.
# Fine with me, because I dislike auto-archiving,
# but you can copy those two functions into this file
# and uncomment the next three lines if you want it to work.
#if [ $TODOTXT_AUTO_ARCHIVE = 1 ]; then
# archive
#fi