-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
rec2tbl
executable file
·57 lines (49 loc) · 1.42 KB
/
rec2tbl
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
#!/usr/bin/env sh
######################################################################
# @author : Gavin Jaeger-Freeborn ([email protected])
# @file : todotemp.sh
# @created : Tue 22 Sep 2020 04:56:58 PM
#
# @description :
######################################################################
DATE=$(date)
RECFILE='schedule.rec'
STATEFMT='{{State = "TODO" ? "\m[R]\fB" & "TODO" & "\fR\m[]" : "\m[G]\fB" & State & "\fR\m[]" }}'
formatDates()
{
# Process one line at a time.
recsel -e "Scheduled >> \"$DATE\"|| Deadline >> \"$DATE\"" --sort 'Scheduled' ${RECFILE} |
while IFS=': ' read -r key val
do
[ -z "$key" ] && echo "" && continue
if [ "$key" = 'Scheduled' ] || [ "$key" = 'Deadline' ] ; then
val="in $((($(date +%s --date "$val")-$(date +%s))/(3600*24))) days"
fi
printf "%s: %s\n" "$key" "$val"
done
}
todos() {
recsel -e "State = 'TODO' && (Scheduled == '' && Deadline == '' ) " ${RECFILE}
}
groffout(){
cat << EOF
.defcolor R rgb 1 0 0
.defcolor B rgb 0 0 1
.defcolor G rgb 0 1 0
.TS
tab(;);
c|c|c|c|c.
\\fBStatus;Name;Class;Deadline;Scheduled\\fR
_
EOF
todos | recfmt "${STATEFMT};{{Name}};{{Class}};\m[R]{{Deadline}}\m[];\m[B]{{Scheduled}}\m[]
"
echo '_'
formatDates | recfmt "${STATEFMT};{{Name}};{{Class}};\m[R]{{Deadline}}\m[];\m[B]{{Scheduled}}\m[]
"
cat << EOF
.TE
EOF
}
groffout | groff -ms -t -Tpdf | zathura -
# vim: set tw=78 ts=2 et sw=2 sr: