aboutsummaryrefslogtreecommitdiffhomepage
path: root/bin/task/context
diff options
context:
space:
mode:
Diffstat (limited to 'bin/task/context')
-rwxr-xr-xbin/task/context31
1 files changed, 31 insertions, 0 deletions
diff --git a/bin/task/context b/bin/task/context
new file mode 100755
index 0000000..d81573b
--- /dev/null
+++ b/bin/task/context
@@ -0,0 +1,31 @@
1#! /bin/bash
2
3LOG_FILE=~/log/context && touch $LOG_FILE
4context="$(cat ~/.task/context)"
5count="$1"
6
7if [ -z "$context" ] || [ "$context" = none ]; then
8 exit 1
9fi
10
11if [ -n "$1" ]; then
12 # Update Log file
13 while read -r ctx sec; do
14 if [ "$ctx" = "$context" ]; then
15 summary=$(( "$sec" + "$count" ))
16 update=true
17 break
18 fi
19 done <$LOG_FILE
20 if [ "$update" = true ]; then
21 sed -i -E "s/^$context.*/$context\t$summary" $LOG_FILE
22 else
23 echo -e "$context\t$count" >>$LOG_FILE
24 fi
25else
26 # Print times for each context
27 while read -r ctx sec; do
28 echo -ne "$ctx\t"
29 date -u -d @"$sec" +%H:%M
30 done <$LOG_FILE
31fi