3 (( $+functions[_path_commands_caching_policy] )) ||
4 _path_commands_caching_policy() {
9 # rebuild if cache is more than a week old
11 (( $#oldp )) && return 0
13 dbfiles=(/usr/share/man/index.(bt|db|dir|pag)(N) \
14 /usr/man/index.(bt|db|dir|pag)(N) \
15 /var/cache/man/index.(bt|db|dir|pag)(N) \
16 /var/catman/index.(bt|db|dir|pag)(N) \
17 /usr/share/man/*/whatis(N))
19 for file in $dbfiles; do
20 [[ $file -nt $1 ]] && return 0
27 case "$(whatis --version)" in
30 zparseopts -D -A args s: r:
31 apropos "${args[-r]:-"$@"}" | fgrep "($args[-s]"
38 local need_desc expl ret=1
40 if zstyle -t ":completion:${curcontext}:" extra-verbose; then
41 local update_policy first
42 if [[ $+_command_descriptions -eq 0 ]]; then
44 typeset -A -g _command_descriptions
46 zstyle -s ":completion:${curcontext}:" cache-policy update_policy
47 [[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" \
48 cache-policy _path_commands_caching_policy
49 if ( [[ -n $first ]] || _cache_invalid command-descriptions ) && \
50 ! _retrieve_cache command-descriptions; then
52 for line in "${(f)$(_call_program command-descriptions _call_whatis -s 1 -r .\\\*\; _call_whatis -s 6 -r .\\\* 2>/dev/null)}"; do
53 [[ -n ${line:#(#b)([^ ]#) #\([^ ]#\)( #\[[^ ]#\]|)[ -]#(*)} ]] && continue;
54 [[ -z $match[1] || -z $match[3] || -z ${${match[1]}:#*:*} ]] && continue;
55 _command_descriptions[$match[1]]=$match[3]
57 _store_cache command-descriptions _command_descriptions
60 (( $#_command_descriptions )) && need_desc=yes
63 if [[ -n $need_desc ]]; then
64 typeset -a dcmds descs cmds matches
66 compadd "$@" -O matches -k commands
67 for cmd in $matches; do
68 desc=$_command_descriptions[$cmd]
69 if [[ -z $desc ]]; then
76 zstyle -s ":completion:${curcontext}:" list-separator sep || sep=--
77 zformat -a descs " $sep " $descs
78 descs=("${(@r:COLUMNS-1:)descs}")
79 _wanted commands expl 'external command' \
80 compadd "$@" -ld descs -a dcmds && ret=0
81 _wanted commands expl 'external command' compadd "$@" -a cmds && ret=0
83 _wanted commands expl 'external command' compadd "$@" -k commands && ret=0