-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasklog
executable file
·45 lines (44 loc) · 883 Bytes
/
tasklog
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
#!/usr/bin/env bash
#
# tasklog
# displays changes since birth for the given task
#
# https://github.com/smemsh/taskwtools/
# https://spdx.org/licenses/GPL-2.0
#
`type -P task` \
rc._forcecolor=0 \
rc.color=0 \
rc.detection=0 \
rc.defaultwidth=0 \
rc.journal.info=1 \
"$@" \
2>&1 \
| tac \
| grep -m1 -B$(((2 << 31) - 1)) ^---- \
| tac \
| tail -n +2 \
| grep -v ^$ \
| gawk -r '
BEGIN {
FS = "\n"
RS = "(^|\n)[[:digit:]-]{10} [[:digit:]:]{8} "
lasttime = ""
}
{
sub("^[[:space:]]+", "", RT)
sub("[[:space:]]+$", "", RT)
time = lasttime # RT of previous is timestamp for this line
lasttime = RT
if (!NF) next # input begins with RT so first $0 is empty
}
{
for (i = 1; i <= NF; i++) {
changeline = $i
if (!changeline) continue # last RT does not consume newline
sub("^[[:space:]]+", "", changeline)
printf("%s %s\n", time, changeline)
}
}
'