forked from ianmkenney/timewarrior_zsh_completion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_timew
120 lines (102 loc) · 3.71 KB
/
_timew
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#compdef _timew timew
# zsh completion for timewarrior 1.7.1
# timewarrior_zsh_completion v0.1.0
_timew() {
local ret=1
if [ -d ${HOME}/.local/share/timewarrior/data ]; then
data_dir="${HOME}/.local/share/timewarrior/data"
fi
if [ -d ${HOME}/.timewarrior/data ]; then
data_dir="${HOME}/.timewarrior/data"
fi
if (( !${+data_dir} )); then
echo "\nCould not find data directory"
return $ret
fi
_arguments -C \
'1:command:->commands' \
'*:ids_tags_hints:->ids_tags_hints' && ret=0
case "$state" in
commands)
_describe 'commands' _commands
;;
ids_tags_hints)
local arr
arr=()
# collect all tag data
vals=$(sed '1,1d' $data_dir/tags.data | \
sed '$d' | \
sed -E "s;^[[:space:]]+\"([[:space:][:alnum:]\._-]+)\":.*$;\1;g")
# add all of the tags to the output array
for i in ${(f)vals}; do arr+=$i; done
# append the predefined hints to the end
arr+=( "${_hints[@]} ")
vals=$(cat ${data_dir}/*-*.data | tail -n 9 | sed -E "s/inc .+# //g")
typeset -i count
count=$(echo $vals | wc -l)
for i in ${(f)vals};
do
arr+="@${count}:${i}"
((count--))
done
_describe 'hints_tags_ids' arr
;;
esac
}
_hints=(
"\:adjust:Automatically correct overlaps"
"\:blank:Leaves tracked time out of a report"
"\:color:Force color on, even if not connected to a TTY"
"\:day:The 24 hours of the current day"
"\:debug:Runs in debug mode, shows many runtime details"
"\:fill:Expand time to fill surrounding available gap"
"\:ids:Displays interval ID numbers in the summary report"
"\:lastmonth:Last month"
"\:lastquarter:Last quarter"
"\:lastweek:Last week"
"\:lastyear:Last year"
"\:month:This month"
"\:nocolor:Force color off, even if connected to a TTY"
"\:quarter:This quarter"
"\:quiet:Turns off all feedback. For automation"
"\:week:This week"
"\:year:This year"
"\:yes:Overrides confirmation by answering \'yes\' to the questions"
"\:yesterday:The 24 hours of the previous day"
)
_commands=(
'annotate:add an annotation to intervals'
'cancel:cancel time tracking'
'config:get and set Timewarrior configuration'
'continue:resume tracking of existing interval'
'day:Summarize the tracked and untracked time over the day'
'day:shows a chart depicting a single day (today by default)'
'delete:delete intervals'
'diagnostics:show diagnostic information'
'export:export tracked time in JSON'
'extensions:list available extensions'
'fill:adjust intervals to fill in surrounding gaps'
'gaps:display time tracking gaps'
'get:display DOM values'
'help:display help'
'join:join intervals'
'lengthen:lengthen intervals'
'modify:change start or end date of an interval'
'month:Summarize the tracked and untracked time over a month'
'month:shows a chart depicting a single month (current month by default)'
'move:change interval start-time'
'report:run an extension report'
'resize:set interval duration'
'revert:revert Timewarrior commands'
'shorten:shorten intervals'
'show:display configuration'
'split:split intervals'
'start:start time tracking'
'stop:stop time tracking'
'summary:display a time-tracking summary'
'tag:add tags to intervals'
'tags:display a list of tags'
'track:add intervals to the database'
'untag:remove tags from intervals'
'week:shows a chart depicting a single week (current week by default)'
)