summaryrefslogtreecommitdiff
path: root/summary
blob: b527afd6a672c9d4cc32f73677943992cdb32b69 (plain)
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
#!/bin/rc -e

flagfmt='o,h,x,a'
if(! ifs=() eval `{aux/getflags $*}){
	aux/usage
	exit usage
}
if(~ $#flago$#flagh$#flagx 000){
	flago=1
	flagh=1
}

cat $home/notes | awk '
	/^   o	/ { o = o $0 "\n"; mode = "o"; next } # important
	/^   -	/ { h = h $0 "\n"; mode = "h"; next } # normal
	/^   x	/ { x = x $0 "\n"; mode = "x"; next } # done
	/^	/ {
		if (! ENVIRON["flaga"]) next
		if (mode == "o") o = o $0 "\n"
		if (mode == "h") h = h $0 "\n"
		if (mode == "x") x = x $0 "\n"
		next
	}
	{ mode = "" }
	END {
		if (ENVIRON["flago"]) printf "%s", o
		if (ENVIRON["flagh"]) printf "%s", h
		if (ENVIRON["flagx"]) printf "%s", x
	}
'