You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
90 lines
1.7 KiB
90 lines
1.7 KiB
#!/bin/zsh
|
|
|
|
function tasktimes() {
|
|
[[ $# -eq 0 ]] && return 1
|
|
|
|
local KEY=${2:-\\1}
|
|
local T
|
|
local D='([0-9]{4}-[0-9]{2}-[0-9]{2})'
|
|
local N='([0-9]+)'
|
|
local EXPR='s/'$D'.*PT('$N'H)?('$N'M)?('$N').*/'${KEY}':\3:\5:\7/;te;d;:e'
|
|
|
|
task $1 info | sed -r ${EXPR} | awk -F: '
|
|
{
|
|
s = (d[$1][2] + $4) % 60
|
|
_m = int((d[$1][2] + $4) / 60)
|
|
m = (d[$1][1] + $3 + _m) % 60
|
|
_h = int((d[$1][1] + $3 + _m) / 60)
|
|
d[$1][0] += $2 + _h
|
|
d[$1][1] = m
|
|
d[$1][2] = s
|
|
}
|
|
END {
|
|
for(i in d)
|
|
printf("%s:%d:%d:%d\n", i, d[i][0], d[i][1], d[i][2])
|
|
}' | sort -t: -k1
|
|
}
|
|
|
|
function tasktimestotal() {
|
|
tasktimes $1 TOTAL
|
|
}
|
|
|
|
function taskdescription() {
|
|
[[ $# -eq 0 ]] && return 1
|
|
task $1 _unique description
|
|
}
|
|
|
|
function taskproject() {
|
|
[[ $# -eq 0 ]] && return 1
|
|
task $1 _unique project
|
|
}
|
|
|
|
function taskurgency() {
|
|
[[ $# -eq 0 ]] && return 1
|
|
task $1 _urgency | cut -d\ -f 4
|
|
}
|
|
|
|
function taskentry() {
|
|
[[ $# -eq 0 ]] && return 1
|
|
task $1 _unique entry
|
|
}
|
|
|
|
function taskend() {
|
|
[[ $# -eq 0 ]] && return 1
|
|
task $1 _unique end
|
|
}
|
|
|
|
function taskuuids() {
|
|
local UUID
|
|
|
|
[[ $# -eq 0 ]] && set -- \( +PENDING or +DONE \)
|
|
for UUID in $(task $@ _uuid)
|
|
do
|
|
printf "%05.2f\037%s\037%s\n" \
|
|
"$(taskurgency $UUID)" \
|
|
"$(taskdescription $UUID)" \
|
|
$UUID
|
|
done | sort -t$'\037' -k1nr,2 | cut -d$'\037' -f3
|
|
}
|
|
|
|
function pendinguuids() {
|
|
taskuuids +PENDING $@
|
|
}
|
|
|
|
function doneuuids() {
|
|
taskuuids +COMPLETED $@
|
|
}
|
|
|
|
function blockeduuids() {
|
|
taskuuids +BLOCKED $@
|
|
}
|
|
|
|
function blockinguuids() {
|
|
taskuuids +BLOCKING $@
|
|
}
|
|
|
|
function deleteduuids() {
|
|
taskuuids +DELETED $@
|
|
}
|
|
|
|
# vim: set et ts=4 sw=4:
|