-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtodo.sh
68 lines (61 loc) · 866 Bytes
/
todo.sh
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
68
function t_list() {
awk '{ printf "%3s. %s\n", NR, $0 }' .todo
}
function t_show() {
t_list | sed "$1p;d"
}
function t_get() {
sed "$1p;d" .todo
}
function t_add() {
echo $1 >> .todo
}
function t_rm() {
sed "$1d" .todo > .todo.out
mv .todo.out .todo
}
function t_git() {
git $1 "`t_get $2`"
}
function todo() {
if [[ $# -eq 0 ]]; then
t_list
else
case "$1" in
list)
t_list
;;
ci)
t_git ci ${2:-1}
t_rm ${2:-1}
t_list
;;
cia)
t_git cia ${2:-1}
t_rm ${2:-1}
t_list
;;
a)
t_add "$2"
t_list
;;
add)
t_add "$2"
t_list
;;
rm)
t_rm ${2:-1}
t_list
;;
show)
t_show ${2:-1}
;;
[0-9]*)
t_show $1
;;
*)
echo "Cannot understand command: $1"
;;
esac
fi
}