-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvkorgbalance.sh
executable file
·101 lines (86 loc) · 3.02 KB
/
vkorgbalance.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/bin/bash
## this is a more or less quick hack that analyzes Org-mode files and
## gives feedback on how I am doing today (or at a given day):
## lists: closed items, created items and items still due
## The metrics are clearly subjective and should be improved
## FIXXMEs:
## - with parameter 1: show only done tasks (incl. habits, ...)
## - add LOGBOOK entries (habits, ...) as well:
## :LOGBOOK:
## - State "DONE" from "TODO" [2012-12-31 Mon 12:42]
FILEPATTERN='*\.org*' ## which files to search in
#FILEPATTERN="*" ## which files to search in
ORGMODEDIR="${HOME}/share/all/org-mode/" ## where org-mode files life
bldgrn='\e[1;32m' ## from https://wiki.archlinux.org/index.php/Color_Bash_Prompt
bldred='\e[1;31m' ## and http://tldp.org/LDP/abs/html/colorizing.html ... works with "bash on Linux"
txtgrn='\e[0;32m' ## does *not* work with zsh or "bash on OS X"
txtred='\e[0;31m'
txtwht='\e[0;37m'
IWhite='\e[0;97m'
BIWhite='\e[1;97m'
if [ "${1}x" = "x" ]; then
## set day to today
DAY=`date +%Y-%m-%d`
else
## using $1 as daystamp
DAY="${1}"
## FIXXME: add check, if $1 is a valid daystamp
fi
cd "${ORGMODEDIR}"
created_and_still_open=`egrep -B 3 ":CREATED: .${DAY}" ${FILEPATTERN} | egrep "\* (NEXT|TODO|STARTED|WAITING)"`
closed=`egrep -B 1 "CLOSED: .${DAY}" ${FILEPATTERN} | egrep "\* DONE"`
deadlinetoday=`egrep -B 1 "DEADLINE: .${DAY}" ${FILEPATTERN} | egrep "\* (NEXT|TODO|STARTED|WAITING)"`
if [ "${created_and_still_open}x" = "x" ]; then
numcreated_and_still_open="0"
else
numcreated_and_still_open=`echo "${created_and_still_open}" | wc -l`
fi
if [ "${closed}x" = "x" ]; then
numclosed="0"
else
numclosed=`echo "${closed}" | wc -l`
fi
if [ "${deadlinetoday}x" = "x" ]; then
numdeadlinetoday="0"
else
numdeadlinetoday=`echo "${deadlinetoday}" | wc -l`
fi
#echo "DEBUG: numcreated_and_still_open [$numcreated_and_still_open] numclosed [$numclosed] numdeadlinetoday [$numdeadlinetoday]"
sum=$(($numcreated_and_still_open-$numclosed))
echo
echo -e ${BIWhite}" ----=== ${DAY} ===----"
echo
if [ "${created_and_still_open}x" != "x" ]; then
echo -e ${BIWhite}" created (& still_open):"
echo -e ${txtred}"${created_and_still_open}"
echo
fi
if [ "${closed}x" != "x" ]; then
echo -e ${BIWhite}" closed:"
echo -e ${txtgrn}"${closed}"
echo
fi
echo
echo -ne ${BIWhite}" ${numcreated_and_still_open} created (& still open) - ${numclosed} done ="
## generating the motivation messages
if [ "${sum}" -lt 1 ]; then
echo -e ${bldgrn}" ${sum} sum"
echo
echo -e ${bldgrn}" Congratulations! Not more tasks generated than solved!"
else
echo -e ${bldred}" ${sum} sum"
echo
echo -e ${bldred}" Sorry, you still have to solve ${sum} issues to get even!"
fi
echo
if [ "${numdeadlinetoday}" -gt 0 ]; then
echo
echo -en ${BIWhite}" Still "
echo -en ${bldred}${numdeadlinetoday}" deadline"
if [ "${numdeadlinetoday}" -gt 1 ]; then
echo -en ${bldred}"s"
fi
echo -e ${BIWhite}" due tough! "
echo
fi
#end