forked from todotxt/todo.txt-cli
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathadd
executable file
·34 lines (30 loc) · 889 Bytes
/
add
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
#!/bin/bash
action=$1
shift
[ "$action" = "usage" ] && {
echo " Customized add:"
echo " add pri PRIORITY \"THING I NEED TO DO +project @context\""
echo " add p PRIORITY \"THING I NEED TO DO +project @context\""
echo " add an item and prioritize it in one step"
echo " add x \"THING I NEEDED TO DO RIGHT NOW\""
echo " add an item and mark it as done in one step"
echo ""
exit
}
PRIORITY=false
DO=false
if [ x"$1" = x"pri" -o x"$1" = x"p" ] && [[ x"$2" = x[a-zA-Z] ]]; then
PRIORITY=$2
shift
shift
elif [ x"$1" = x"x" ]; then
DO=true
shift
fi
# call back to the main script to add
if "$TODO_SH" command add "$@"; then
# figure out the line of what we just added, and "do" it
line=`sed -n '$ =' "$TODO_FILE"`
[ $PRIORITY != false ] && "$TODO_SH" command pri "$line" $PRIORITY
$DO && "$TODO_SH" command do "$line"
fi