"Fossies" - the Fresh Open Source Software Archive

Member "googler-4.3.2/auto-completion/zsh/_googler" (21 Jan 2021, 3055 Bytes) of package /linux/misc/googler-4.3.2.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 last Fossies "Diffs" side-by-side code changes report for "_googler": 4.2_vs_4.3.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     '(-g --geoloc)'{-g,--geoloc}'[specify geolocation]:code'
   45     '(-x --exact)'{-x,--exact}'[disable automatic spelling correction]'
   46     '(--colorize)--colorize[whether to colorize output]:auto/always/never'
   47     '(-C --nocolor)'{-C,--nocolor}'[disable color output]'
   48     '(--colors)--colors[set output colors]:six-letter string'
   49     '(-j --first --lucky)'{-j,--first,--lucky}'[open the first result in a web browser]'
   50     '(-t --time)'{-t,--time}'[time limit search]:period (h/d/w/m/y + number)'
   51     '(--from)--from[starting date/month/year of date range]:date m/d/yyyy'
   52     '(--to)--to[ending date/month/year of date range]:date m/d/yyyy'
   53     '(-w --site)'{-w,--site}'[search a site using Google]:domain'
   54     '(-e --exclude)'{-e,--exclude}'[exclude site from results]:domain'
   55     '(--unfilter)--unfilter[do not omit similar results]'
   56     '(-p --proxy)'{-p,--proxy}'[proxy in HOST:PORT format]:proxy details'
   57     '(--notweak)--notweak[disable TCP optimizations, forced TLS 1.2]'
   58     '(--json)--json[output in JSON format; implies --exact and --noprompt]'
   59     '(--url-handler)--url-handler[cli script or utility]:url opener'
   60     '(--show-browser-logs)--show-browser-logs[do not suppress browser output]'
   61     '(--np --noprompt)'{--np,--noprompt}'[perform search and exit, do not prompt for further interactions]'
   62     '(-u --upgrade)'{-u,--upgrade}'[perform in-place self-upgrade]'
   63     '(--include-git)--include-git[when used with --upgrade, upgrade to git master]'
   64     '(- : *)'{-v,--version}'[show version number and exit]'
   65     '(-d --debug)'{-d,--debug}'[enable debugging]'
   66     '*:::query:_googler_complete_query'
   67 )
   68 _arguments -S -s $args