"Fossies" - the Fresh Open Source Software Archive

Member "googler-4.1/auto-completion/zsh/_googler" (30 Apr 2020, 2923 Bytes) of package /linux/misc/googler-4.1.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "_googler": 4.0_vs_4.1.

    1 #compdef googler
    2 #
    3 # Completion definition for googler.
    4 #
    5 # Author:
    6 #   Zhiming Wang <zmwangx@gmail.com>
    7 #
    8 
    9 setopt localoptions noshwordsplit noksharrays
   10 
   11 _googler_query_caching_policy () {
   12     # rebuild if cache is more than a day old
   13     local -a oldp
   14     oldp=( $1(Nm+1) )
   15     (( $#oldp ))
   16 }
   17 
   18 _googler_complete_query () {
   19     local prefix=$words[CURRENT]
   20     [[ -n $prefix && $prefix != -* ]] || return
   21 
   22     local cache_id=googler_$prefix
   23     zstyle -s :completion:${curcontext}: cache-policy update_policy
   24     [[ -z $update_policy ]] && zstyle :completion:${curcontext}: cache_policy _googler_query_caching_policy
   25 
   26     local -a completions
   27     if _cache_invalid $cache_id || ! _retrieve_cache $cache_id; then
   28         completions=( ${(f)"$(googler --complete $prefix 2>/dev/null)"} )
   29         _store_cache $cache_id completions
   30     fi
   31 
   32     compadd $@ -- $completions
   33 }
   34 
   35 local -a args
   36 args=(
   37     '(- : *)'{-h,--help}'[show help text and exit]'
   38     '(-s --start)'{-s,--start}'[start at the Nth result]:result number'
   39     '(-n --count)'{-n,--count}'[show specified number of results (default 10)]:count'
   40     '(-N --news)'{-N,--news}'[show results from news section]'
   41     '(-V --videos)'{-V,--videos}'[show results from videos section]'
   42     '(-c --tld)'{-c,--tld}'[country-specific search with top-level domain]:top level domain without dot'
   43     '(-l --lang)'{-l,--lang}'[display in specified language]:language code'
   44     '(-x --exact)'{-x,--exact}'[disable automatic spelling correction]'
   45     '(--colorize)--colorize[whether to colorize output]:auto/always/never'
   46     '(-C --nocolor)'{-C,--nocolor}'[disable color output]'
   47     '(--colors)--colors[set output colors]:six-letter string'
   48     '(-j --first --lucky)'{-j,--first,--lucky}'[open the first result in a web browser]'
   49     '(-t --time)'{-t,--time}'[time limit search]:period (h/d/w/m/y + number)'
   50     '(--from)--from[starting date/month/year of date range]:date m/d/yyyy'
   51     '(--to)--to[ending date/month/year of date range]:date m/d/yyyy'
   52     '(-w --site)'{-w,--site}'[search a site using Google]:domain'
   53     '(--unfilter)--unfilter[do not omit similar results]'
   54     '(-p --proxy)'{-p,--proxy}'[proxy in HOST:PORT format]:proxy details'
   55     '(--notweak)--notweak[disable TCP optimizations, forced TLS 1.2]'
   56     '(--json)--json[output in JSON format; implies --exact and --noprompt]'
   57     '(--url-handler)--url-handler[cli script or utility]:url opener'
   58     '(--show-browser-logs)--show-browser-logs[do not suppress browser output]'
   59     '(--np --noprompt)'{--np,--noprompt}'[perform search and exit, do not prompt for further interactions]'
   60     '(-u --upgrade)'{-u,--upgrade}'[perform in-place self-upgrade]'
   61     '(--include-git)--include-git[when used with --upgrade, upgrade to git master]'
   62     '(- : *)'{-v,--version}'[show version number and exit]'
   63     '(-d --debug)'{-d,--debug}'[enable debugging]'
   64     '*:::query:_googler_complete_query'
   65 )
   66 _arguments -S -s $args