-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·59 lines (50 loc) · 731 Bytes
/
init.sh
File metadata and controls
executable file
·59 lines (50 loc) · 731 Bytes
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
_t(){
_arguments -s : \
'-e[Open editor.]' \
'-d[Delete task.]'
_files -W "$TODOS"/
}
compdef _t t
t() {
edit(){
$EDITOR "$1"
}
delete(){
rm "$1" -r
}
all(){
if hash tree 2>/dev/null; then
tree "$TODOS" --dirsfirst
else
ls "$TODOS" -1
fi
}
show(){
cat $1
}
new(){
touch $1
}
show_or_create(){
if test -f $1
then
show $1
else
new $1
fi
}
analize_options(){
while getopts e:d: opt
do
case "$opt" in
e) edit "$TODOS"/"$OPTARG";;
d) delete "$TODOS"/"$OPTARG";;
esac
done
}
case $# in
0) all;;
1) show_or_create "$TODOS"/"$1";;
2) analize_options $1 $2 ;;
esac
}