-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmtl-cat
executable file
·74 lines (70 loc) · 1.59 KB
/
mtl-cat
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
69
70
71
72
73
74
#!/bin/bash
. mtl-funcs
showUsage() {
cat <<EOF
Usage:
cat doc ~ cats a document last store point
cat doc done
cat doc todo
cat doc to doc2
cat doc done to doc2
cat doc todo to doc2
cat doc:1 todo to doc2
EOF
}
if [ $# -gt 0 ]; then
DOCNM=$(resolvedoc $1)
DOC=$(getdocname $DOCNM)
BLOB=$(getblob "$DOCNM" 1)
if [[ $BLOB != "" ]]; then
CMD="cat .mtl/d/$BLOB"
shift
if [ $# -gt 0 ]; then # many of these should improve by real parser or just better greps + awk for cleaning titles
if [ $1 == "todo" ]; then
CMD="$CMD | grep -v '\(^[[:space:]]*\)\(+\|\*\|^\^\|^¨\)'"
shift
elif [ $1 == "todonow" ]; then
CMD="$CMD | grep -v '\(^[[:space:]]*\)\(+\|\*\|^\^\|^¨\)'"
shift
elif [ $1 == "done" ]; then
CMD="$CMD | grep -v '\(^[[:space:]]*\)\(^\-\|^\~\|^\*\)'"
shift
elif [ $1 == "notes" ]; then
CMD="$CMD | grep -v '\(^[[:space:]]*\)\(^\-\|^\~\|^\+\)'"
shift
elif [ $1 == "urgent" ]; then
CMD="$CMD | grep '!!'"
shift
elif [ $1 == "tags" ]; then
CMD="$CMD | grep '\:'"
shift
elif [ $1 == "peers" ]; then
CMD="$CMD | grep '@'"
shift
elif [ $1 == "clients" ]; then
CMD="$CMD | grep '\$'" #todo doesn't work
shift
elif [ $1 == "find" ]; then
CMD="$CMD | grep '$2'"
shift
shift
fi
fi
if [ $# -gt 1 ] && [ "$1" == "to" ]; then
DOC2=$(getdoc $2)
echo "$DOC --> $DOC2"
CMD="$CMD > .mtl/${DOC2}"
echo "$BLOB" > .mtl/${DOC2}.src
fi
if [ "$CMD" == "" ]; then
showUsage
else
#echo "$CMD"
eval "$CMD"
fi
else
echo "err: no index file, try the ~w option"
fi
else
showUsage
fi