-
Notifications
You must be signed in to change notification settings - Fork 1
/
_zdict
37 lines (32 loc) · 1.36 KB
/
_zdict
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
#compdef zdict
function _zdict () {
_arguments\
{-h,--help}'[show help message and exit]'\
{-v,--version}"[show program\'s version number and exit]"\
{-d,--disable-db-cache}'[temporarily not using the result from db cache]'\
{-t,--query-timeout}'[set timeout for every query]:set timeout:(5)'\
{-j,--jobs}'[allow N jobs at once]:JOBS:'\
{-sp,--show-provider}'[show the dictionary provider]'\
{-su,--show-url}'[show the url of the queried word]'\
{-dt,--dict}'[choose the dictionary you want]:dictionaries:{_get_zdict_available_dicts}'\
{-ld,--list-dicts}'[show supported dictionaries]'\
{-V,--verbose}'[show more information for the queried word]'\
{-c,--force-color}'[force color printing]'\
'--dump[Dump the querying history, can be filtered with regex]:DUMP:'\
'*:history:{_get_zdict_history}'
}
local _zdict_available_dict_list=()
_get_zdict_available_dicts () {
if [ "$_zdict_available_dict_list" = "" ]; then
if command -v zdict >/dev/null 2>&1; then
_zdict_available_dict_list=($(zdict -ld | sed 's/: .*//' | tr '\n' ' '))
fi
fi
_values -s , dicts $_zdict_available_dict_list all
}
_get_zdict_history () {
if command -v zdict >/dev/null 2>&1; then
_arguments '*:history:(${(f)"$(zdict --dump)"})'
fi
}
_zdict "$@"