_rg (27629B)
1 #compdef rg 2 3 ## 4 # zsh completion function for ripgrep 5 # 6 # Run ci/test_complete.sh after building to ensure that the options supported by 7 # this function stay in synch with the `rg` binary. 8 # 9 # For convenience, a completion reference guide is included at the bottom of 10 # this file. 11 # 12 # Originally based on code from the zsh-users project — see copyright notice 13 # below. 14 15 _rg() { 16 local curcontext=$curcontext no='!' descr ret=1 17 local -a context line state state_descr args tmp suf 18 local -A opt_args 19 20 # ripgrep has many options which negate the effect of a more common one — for 21 # example, `--no-column` to negate `--column`, and `--messages` to negate 22 # `--no-messages`. There are so many of these, and they're so infrequently 23 # used, that some users will probably find it irritating if they're completed 24 # indiscriminately, so let's not do that unless either the current prefix 25 # matches one of those negation options or the user has the `complete-all` 26 # style set. Note that this prefix check has to be updated manually to account 27 # for all of the potential negation options listed below! 28 if 29 # We also want to list all of these options during testing 30 [[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] || 31 # (--[imnp]* => --ignore*, --messages, --no-*, --pcre2-unicode) 32 [[ $PREFIX$SUFFIX == --[imnp]* ]] || 33 zstyle -t ":complete:$curcontext:*" complete-all 34 then 35 no= 36 fi 37 38 # We make heavy use of argument groups here to prevent the option specs from 39 # growing unwieldy. These aren't supported in zsh <5.4, though, so we'll strip 40 # them out below if necessary. This makes the exclusions inaccurate on those 41 # older versions, but oh well — it's not that big a deal 42 args=( 43 + '(exclusive)' # Misc. fully exclusive options 44 '(: * -)'{-h,--help}'[display help information]' 45 '(: * -)'{-V,--version}'[display version information]' 46 '(: * -)'--pcre2-version'[print the version of PCRE2 used by ripgrep, if available]' 47 48 + '(buffered)' # buffering options 49 '--line-buffered[force line buffering]' 50 $no"--no-line-buffered[don't force line buffering]" 51 '--block-buffered[force block buffering]' 52 $no"--no-block-buffered[don't force block buffering]" 53 54 + '(case)' # Case-sensitivity options 55 {-i,--ignore-case}'[search case-insensitively]' 56 {-s,--case-sensitive}'[search case-sensitively]' 57 {-S,--smart-case}'[search case-insensitively if pattern is all lowercase]' 58 59 + '(context-a)' # Context (after) options 60 '(context-c)'{-A+,--after-context=}'[specify lines to show after each match]:number of lines' 61 62 + '(context-b)' # Context (before) options 63 '(context-c)'{-B+,--before-context=}'[specify lines to show before each match]:number of lines' 64 65 + '(context-c)' # Context (combined) options 66 '(context-a context-b)'{-C+,--context=}'[specify lines to show before and after each match]:number of lines' 67 68 + '(column)' # Column options 69 '--column[show column numbers for matches]' 70 $no"--no-column[don't show column numbers for matches]" 71 72 + '(count)' # Counting options 73 {-c,--count}'[only show count of matching lines for each file]' 74 '--count-matches[only show count of individual matches for each file]' 75 76 + '(encoding)' # Encoding options 77 {-E+,--encoding=}'[specify text encoding of files to search]: :_rg_encodings' 78 $no'--no-encoding[use default text encoding]' 79 80 + file # File-input options 81 '(1)*'{-f+,--file=}'[specify file containing patterns to search for]: :_files' 82 83 + '(file-match)' # Files with/without match options 84 '(stats)'{-l,--files-with-matches}'[only show names of files with matches]' 85 '(stats)--files-without-match[only show names of files without matches]' 86 87 + '(file-name)' # File-name options 88 {-H,--with-filename}'[show file name for matches]' 89 {-I,--no-filename}"[don't show file name for matches]" 90 91 + '(file-system)' # File system options 92 "--one-file-system[don't descend into directories on other file systems]" 93 $no'--no-one-file-system[descend into directories on other file systems]' 94 95 + '(fixed)' # Fixed-string options 96 {-F,--fixed-strings}'[treat pattern as literal string instead of regular expression]' 97 $no"--no-fixed-strings[don't treat pattern as literal string]" 98 99 + '(follow)' # Symlink-following options 100 {-L,--follow}'[follow symlinks]' 101 $no"--no-follow[don't follow symlinks]" 102 103 + glob # File-glob options 104 '*'{-g+,--glob=}'[include/exclude files matching specified glob]:glob' 105 '*--iglob=[include/exclude files matching specified case-insensitive glob]:glob' 106 107 + '(heading)' # Heading options 108 '(pretty-vimgrep)--heading[show matches grouped by file name]' 109 "(pretty-vimgrep)--no-heading[don't show matches grouped by file name]" 110 111 + '(hidden)' # Hidden-file options 112 '--hidden[search hidden files and directories]' 113 $no"--no-hidden[don't search hidden files and directories]" 114 115 + '(hybrid)' # hybrid regex options 116 '--auto-hybrid-regex[dynamically use PCRE2 if necessary]' 117 $no"--no-auto-hybrid-regex[don't dynamically use PCRE2 if necessary]" 118 119 + '(ignore)' # Ignore-file options 120 "(--no-ignore-global --no-ignore-parent --no-ignore-vcs --no-ignore-dot)--no-ignore[don't respect ignore files]" 121 $no'(--ignore-global --ignore-parent --ignore-vcs --ignore-dot)--ignore[respect ignore files]' 122 123 + '(ignore-file-case-insensitive)' # Ignore-file case sensitivity options 124 '--ignore-file-case-insensitive[process ignore files case insensitively]' 125 $no'--no-ignore-file-case-insensitive[process ignore files case sensitively]' 126 127 + '(ignore-global)' # Global ignore-file options 128 "--no-ignore-global[don't respect global ignore files]" 129 $no'--ignore-global[respect global ignore files]' 130 131 + '(ignore-parent)' # Parent ignore-file options 132 "--no-ignore-parent[don't respect ignore files in parent directories]" 133 $no'--ignore-parent[respect ignore files in parent directories]' 134 135 + '(ignore-vcs)' # VCS ignore-file options 136 "--no-ignore-vcs[don't respect version control ignore files]" 137 $no'--ignore-vcs[respect version control ignore files]' 138 139 + '(ignore-dot)' # .ignore-file options 140 "--no-ignore-dot[don't respect .ignore files]" 141 $no'--ignore-dot[respect .ignore files]' 142 143 + '(json)' # JSON options 144 '--json[output results in JSON Lines format]' 145 $no"--no-json[don't output results in JSON Lines format]" 146 147 + '(line-number)' # Line-number options 148 {-n,--line-number}'[show line numbers for matches]' 149 {-N,--no-line-number}"[don't show line numbers for matches]" 150 151 + '(line-terminator)' # Line-terminator options 152 '--crlf[use CRLF as line terminator]' 153 $no"--no-crlf[don't use CRLF as line terminator]" 154 '(text)--null-data[use NUL as line terminator]' 155 156 + '(max-columns-preview)' # max column preview options 157 '--max-columns-preview[show preview for long lines (with -M)]' 158 $no"--no-max-columns-preview[don't show preview for long lines (with -M)]" 159 160 + '(max-depth)' # Directory-depth options 161 '--max-depth=[specify max number of directories to descend]:number of directories' 162 '!--maxdepth=:number of directories' 163 164 + '(messages)' # Error-message options 165 '(--no-ignore-messages)--no-messages[suppress some error messages]' 166 $no"--messages[don't suppress error messages affected by --no-messages]" 167 168 + '(messages-ignore)' # Ignore-error message options 169 "--no-ignore-messages[don't show ignore-file parse error messages]" 170 $no'--ignore-messages[show ignore-file parse error messages]' 171 172 + '(mmap)' # mmap options 173 '--mmap[search using memory maps when possible]' 174 "--no-mmap[don't search using memory maps]" 175 176 + '(multiline)' # Multiline options 177 {-U,--multiline}'[permit matching across multiple lines]' 178 $no'(multiline-dotall)--no-multiline[restrict matches to at most one line each]' 179 180 + '(multiline-dotall)' # Multiline DOTALL options 181 '(--no-multiline)--multiline-dotall[allow "." to match newline (with -U)]' 182 $no"(--no-multiline)--no-multiline-dotall[don't allow \".\" to match newline (with -U)]" 183 184 + '(only)' # Only-match options 185 {-o,--only-matching}'[show only matching part of each line]' 186 187 + '(passthru)' # Pass-through options 188 '(--vimgrep)--passthru[show both matching and non-matching lines]' 189 '!(--vimgrep)--passthrough' 190 191 + '(pcre2)' # PCRE2 options 192 {-P,--pcre2}'[enable matching with PCRE2]' 193 $no'(pcre2-unicode)--no-pcre2[disable matching with PCRE2]' 194 195 + '(pcre2-unicode)' # PCRE2 Unicode options 196 $no'(--no-pcre2 --no-pcre2-unicode)--pcre2-unicode[enable PCRE2 Unicode mode (with -P)]' 197 '(--no-pcre2 --pcre2-unicode)--no-pcre2-unicode[disable PCRE2 Unicode mode (with -P)]' 198 199 + '(pre)' # Preprocessing options 200 '(-z --search-zip)--pre=[specify preprocessor utility]:preprocessor utility:_command_names -e' 201 $no'--no-pre[disable preprocessor utility]' 202 203 + pre-glob # Preprocessing glob options 204 '*--pre-glob[include/exclude files for preprocessing with --pre]' 205 206 + '(pretty-vimgrep)' # Pretty/vimgrep display options 207 '(heading)'{-p,--pretty}'[alias for --color=always --heading -n]' 208 '(heading passthru)--vimgrep[show results in vim-compatible format]' 209 210 + regexp # Explicit pattern options 211 '(1 file)*'{-e+,--regexp=}'[specify pattern]:pattern' 212 213 + '(replace)' # Replacement options 214 {-r+,--replace=}'[specify string used to replace matches]:replace string' 215 216 + '(sort)' # File-sorting options 217 '(threads)--sort=[sort results in ascending order (disables parallelism)]:sort method:(( 218 none\:"no sorting" 219 path\:"sort by file path" 220 modified\:"sort by last modified time" 221 accessed\:"sort by last accessed time" 222 created\:"sort by creation time" 223 ))' 224 '(threads)--sortr=[sort results in descending order (disables parallelism)]:sort method:(( 225 none\:"no sorting" 226 path\:"sort by file path" 227 modified\:"sort by last modified time" 228 accessed\:"sort by last accessed time" 229 created\:"sort by creation time" 230 ))' 231 '!(threads)--sort-files[sort results by file path (disables parallelism)]' 232 233 + '(stats)' # Statistics options 234 '(--files file-match)--stats[show search statistics]' 235 $no"--no-stats[don't show search statistics]" 236 237 + '(text)' # Binary-search options 238 {-a,--text}'[search binary files as if they were text]' 239 "--binary[search binary files, don't print binary data]" 240 $no"--no-binary[don't search binary files]" 241 $no"(--null-data)--no-text[don't search binary files as if they were text]" 242 243 + '(threads)' # Thread-count options 244 '(sort)'{-j+,--threads=}'[specify approximate number of threads to use]:number of threads' 245 246 + '(trim)' # Trim options 247 '--trim[trim any ASCII whitespace prefix from each line]' 248 $no"--no-trim[don't trim ASCII whitespace prefix from each line]" 249 250 + type # Type options 251 '*'{-t+,--type=}'[only search files matching specified type]: :_rg_types' 252 '*--type-add=[add new glob for specified file type]: :->typespec' 253 '*--type-clear=[clear globs previously defined for specified file type]: :_rg_types' 254 # This should actually be exclusive with everything but other type options 255 '(: *)--type-list[show all supported file types and their associated globs]' 256 '*'{-T+,--type-not=}"[don't search files matching specified file type]: :_rg_types" 257 258 + '(word-line)' # Whole-word/line match options 259 {-w,--word-regexp}'[only show matches surrounded by word boundaries]' 260 {-x,--line-regexp}'[only show matches surrounded by line boundaries]' 261 262 + '(zip)' # Compression options 263 '(--pre)'{-z,--search-zip}'[search in compressed files]' 264 $no"--no-search-zip[don't search in compressed files]" 265 266 + misc # Other options — no need to separate these at the moment 267 '(-b --byte-offset)'{-b,--byte-offset}'[show 0-based byte offset for each matching line]' 268 '--color=[specify when to use colors in output]:when:(( 269 never\:"never use colors" 270 auto\:"use colors or not based on stdout, TERM, etc." 271 always\:"always use colors" 272 ansi\:"always use ANSI colors (even on Windows)" 273 ))' 274 '*--colors=[specify color and style settings]: :->colorspec' 275 '--context-separator=[specify string used to separate non-continuous context lines in output]:separator' 276 '--debug[show debug messages]' 277 '--dfa-size-limit=[specify upper size limit of generated DFA]:DFA size (bytes)' 278 "(1 stats)--files[show each file that would be searched (but don't search)]" 279 '*--ignore-file=[specify additional ignore file]:ignore file:_files' 280 '(-v --invert-match)'{-v,--invert-match}'[invert matching]' 281 '(-M --max-columns)'{-M+,--max-columns=}'[specify max length of lines to print]:number of bytes' 282 '(-m --max-count)'{-m+,--max-count=}'[specify max number of matches per file]:number of matches' 283 '--max-filesize=[specify size above which files should be ignored]:file size (bytes)' 284 "--no-config[don't load configuration files]" 285 '(-0 --null)'{-0,--null}'[print NUL byte after file names]' 286 '--path-separator=[specify path separator to use when printing file names]:separator' 287 '(-q --quiet)'{-q,--quiet}'[suppress normal output]' 288 '--regex-size-limit=[specify upper size limit of compiled regex]:regex size (bytes)' 289 '*'{-u,--unrestricted}'[reduce level of "smart" searching]' 290 291 + operand # Operands 292 '(--files --type-list file regexp)1: :_guard "^-*" pattern' 293 '(--type-list)*: :_files' 294 ) 295 296 # This is used with test_complete.sh to verify that there are no options 297 # listed in the help output that aren't also defined here 298 [[ $_RG_COMPLETE_LIST_ARGS == (1|t*|y*) ]] && { 299 print -rl - $args 300 return 0 301 } 302 303 # Strip out argument groups where unsupported (see above) 304 [[ $ZSH_VERSION == (4|5.<0-3>)(.*)# ]] && 305 args=( ${(@)args:#(#i)(+|[a-z0-9][a-z0-9_-]#|\([a-z0-9][a-z0-9_-]#\))} ) 306 307 _arguments -C -s -S : $args && ret=0 308 309 case $state in 310 colorspec) 311 if [[ ${IPREFIX#--*=}$PREFIX == [^:]# ]]; then 312 suf=( -qS: ) 313 tmp=( 314 'column:specify coloring for column numbers' 315 'line:specify coloring for line numbers' 316 'match:specify coloring for match text' 317 'path:specify coloring for file names' 318 ) 319 descr='color/style type' 320 elif [[ ${IPREFIX#--*=}$PREFIX == (column|line|match|path):[^:]# ]]; then 321 suf=( -qS: ) 322 tmp=( 323 'none:clear color/style for type' 324 'bg:specify background color' 325 'fg:specify foreground color' 326 'style:specify text style' 327 ) 328 descr='color/style attribute' 329 elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:(bg|fg):[^:]# ]]; then 330 tmp=( black blue green red cyan magenta yellow white ) 331 descr='color name or r,g,b' 332 elif [[ ${IPREFIX#--*=}$PREFIX == [^:]##:style:[^:]# ]]; then 333 tmp=( {,no}bold {,no}intense {,no}underline ) 334 descr='style name' 335 else 336 _message -e colorspec 'no more arguments' 337 fi 338 339 (( $#tmp )) && { 340 compset -P '*:' 341 _describe -t colorspec $descr tmp $suf && ret=0 342 } 343 ;; 344 345 typespec) 346 if compset -P '[^:]##:include:'; then 347 _sequence -s , _rg_types && ret=0 348 # @todo This bit in particular could be better, but it's a little 349 # complex, and attempting to solve it seems to run us up against a crash 350 # bug — zsh # 40362 351 elif compset -P '[^:]##:'; then 352 _message 'glob or include directive' && ret=1 353 elif [[ ! -prefix *:* ]]; then 354 _rg_types -qS : && ret=0 355 fi 356 ;; 357 esac 358 359 return ret 360 } 361 362 # Complete encodings 363 _rg_encodings() { 364 local -a expl 365 local -aU _encodings 366 367 # This is impossible to read, but these encodings rarely if ever change, so it 368 # probably doesn't matter. They are derived from the list given here: 369 # https://encoding.spec.whatwg.org/#concept-encoding-get 370 _encodings=( 371 {{,us-}ascii,arabic,chinese,cyrillic,greek{,8},hebrew,korean} 372 logical visual mac {,cs}macintosh x-mac-{cyrillic,roman,ukrainian} 373 866 ibm{819,866} csibm866 374 big5{,-hkscs} {cn-,cs}big5 x-x-big5 375 cp{819,866,125{0..8}} x-cp125{0..8} 376 csiso2022{jp,kr} csiso8859{6,8}{e,i} 377 csisolatin{{1..6},9} csisolatin{arabic,cyrillic,greek,hebrew} 378 ecma-{114,118} asmo-708 elot_928 sun_eu_greek 379 euc-{jp,kr} x-euc-jp cseuckr cseucpkdfmtjapanese 380 {,x-}gbk csiso58gb231280 gb18030 {,cs}gb2312 gb_2312{,-80} hz-gb-2312 381 iso-2022-{cn,cn-ext,jp,kr} 382 iso8859{,-}{{1..11},13,14,15} 383 iso-8859-{{1..11},{6,8}-{e,i},13,14,15,16} iso_8859-{{1..9},15} 384 iso_8859-{1,2,6,7}:1987 iso_8859-{3,4,5,8}:1988 iso_8859-9:1989 385 iso-ir-{58,100,101,109,110,126,127,138,144,148,149,157} 386 koi{,8,8-r,8-ru,8-u,8_r} cskoi8r 387 ks_c_5601-{1987,1989} ksc{,_}5691 csksc56011987 388 latin{1..6} l{{1..6},9} 389 shift{-,_}jis csshiftjis {,x-}sjis ms_kanji ms932 390 utf{,-}8 utf-16{,be,le} unicode-1-1-utf-8 391 windows-{31j,874,949,125{0..8}} dos-874 tis-620 ansi_x3.4-1968 392 x-user-defined auto none 393 ) 394 395 _wanted encodings expl encoding compadd -a "$@" - _encodings 396 } 397 398 # Complete file types 399 _rg_types() { 400 local -a expl 401 local -aU _types 402 403 _types=( ${(@)${(f)"$( _call_program types rg --type-list )"}%%:*} ) 404 405 _wanted types expl 'file type' compadd -a "$@" - _types 406 } 407 408 _rg "$@" 409 410 ################################################################################ 411 # ZSH COMPLETION REFERENCE 412 # 413 # For the convenience of developers who aren't especially familiar with zsh 414 # completion functions, a brief reference guide follows. This is in no way 415 # comprehensive; it covers just enough of the basic structure, syntax, and 416 # conventions to help someone make simple changes like adding new options. For 417 # more complete documentation regarding zsh completion functions, please see the 418 # following: 419 # 420 # * http://zsh.sourceforge.net/Doc/Release/Completion-System.html 421 # * https://github.com/zsh-users/zsh/blob/master/Etc/completion-style-guide 422 # 423 # OVERVIEW 424 # 425 # Most zsh completion functions are defined in terms of `_arguments`, which is a 426 # shell function that takes a series of argument specifications. The specs for 427 # `rg` are stored in an array, which is common for more complex functions; the 428 # elements of the array are passed to `_arguments` on invocation. 429 # 430 # ARGUMENT-SPECIFICATION SYNTAX 431 # 432 # The following is a contrived example of the argument specs for a simple tool: 433 # 434 # '(: * -)'{-h,--help}'[display help information]' 435 # '(-q -v --quiet --verbose)'{-q,--quiet}'[decrease output verbosity]' 436 # '!(-q -v --quiet --verbose)--silent' 437 # '(-q -v --quiet --verbose)'{-v,--verbose}'[increase output verbosity]' 438 # '--color=[specify when to use colors]:when:(always never auto)' 439 # '*:example file:_files' 440 # 441 # Although there may appear to be six specs here, there are actually nine; we 442 # use brace expansion to combine specs for options that go by multiple names, 443 # like `-q` and `--quiet`. This is customary, and ties in with the fact that zsh 444 # merges completion possibilities together when they have the same description. 445 # 446 # The first line defines the option `-h`/`--help`. With most tools, it isn't 447 # useful to complete anything after `--help` because it effectively overrides 448 # all others; the `(: * -)` at the beginning of the spec tells zsh not to 449 # complete any other operands (`:` and `*`) or options (`-`) after this one has 450 # been used. The `[...]` at the end associates a description with `-h`/`--help`; 451 # as mentioned, zsh will see the identical descriptions and merge these options 452 # together when offering completion possibilities. 453 # 454 # The next line defines `-q`/`--quiet`. Here we don't want to suppress further 455 # completions entirely, but we don't want to offer `-q` if `--quiet` has been 456 # given (since they do the same thing), nor do we want to offer `-v` (since it 457 # doesn't make sense to be quiet and verbose at the same time). We don't need to 458 # tell zsh not to offer `--quiet` a second time, since that's the default 459 # behaviour, but since this line expands to two specs describing `-q` *and* 460 # `--quiet` we do need to explicitly list all of them here. 461 # 462 # The next line defines a hidden option `--silent` — maybe it's a deprecated 463 # synonym for `--quiet`. The leading `!` indicates that zsh shouldn't offer this 464 # option during completion. The benefit of providing a spec for an option that 465 # shouldn't be completed is that, if someone *does* use it, we can correctly 466 # suppress completion of other options afterwards. 467 # 468 # The next line defines `-v`/`--verbose`; this works just like `-q`/`--quiet`. 469 # 470 # The next line defines `--color`. In this example, `--color` doesn't have a 471 # corresponding short option, so we don't need to use brace expansion. Further, 472 # there are no other options it's exclusive with (just itself), so we don't need 473 # to define those at the beginning. However, it does take a mandatory argument. 474 # The `=` at the end of `--color=` indicates that the argument may appear either 475 # like `--color always` or like `--color=always`; this is how most GNU-style 476 # command-line tools work. The corresponding short option would normally use `+` 477 # — for example, `-c+` would allow either `-c always` or `-calways`. For this 478 # option, the arguments are known ahead of time, so we can simply list them in 479 # parentheses at the end (`when` is used as the description for the argument). 480 # 481 # The last line defines an operand (a non-option argument). In this example, the 482 # operand can be used any number of times (the leading `*`), and it should be a 483 # file path, so we tell zsh to call the `_files` function to complete it. The 484 # `example file` in the middle is the description to use for this operand; we 485 # could use a space instead to accept the default provided by `_files`. 486 # 487 # GROUPING ARGUMENT SPECIFICATIONS 488 # 489 # Newer versions of zsh support grouping argument specs together. All specs 490 # following a `+` and then a group name are considered to be members of the 491 # named group. Grouping is useful mostly for organisational purposes; it makes 492 # the relationship between different options more obvious, and makes it easier 493 # to specify exclusions. 494 # 495 # We could rewrite our example above using grouping as follows: 496 # 497 # '(: * -)'{-h,--help}'[display help information]' 498 # '--color=[specify when to use colors]:when:(always never auto)' 499 # '*:example file:_files' 500 # + '(verbosity)' 501 # {-q,--quiet}'[decrease output verbosity]' 502 # '!--silent' 503 # {-v,--verbose}'[increase output verbosity]' 504 # 505 # Here we take advantage of a useful feature of spec grouping — when the group 506 # name is surrounded by parentheses, as in `(verbosity)`, it tells zsh that all 507 # of the options in that group are exclusive with each other. As a result, we 508 # don't need to manually list out the exclusions at the beginning of each 509 # option. 510 # 511 # Groups can also be referred to by name in other argument specs; for example: 512 # 513 # '(xyz)--aaa' '*: :_files' 514 # + xyz --xxx --yyy --zzz 515 # 516 # Here we use the group name `xyz` to tell zsh that `--xxx`, `--yyy`, and 517 # `--zzz` are not to be completed after `--aaa`. This makes the exclusion list 518 # much more compact and reusable. 519 # 520 # CONVENTIONS 521 # 522 # zsh completion functions generally adhere to the following conventions: 523 # 524 # * Use two spaces for indentation 525 # * Combine specs for options with different names using brace expansion 526 # * In combined specs, list the short option first (as in `{-a,--text}`) 527 # * Use `+` or `=` as described above for options that take arguments 528 # * Provide a description for all options, option-arguments, and operands 529 # * Capitalise/punctuate argument descriptions as phrases, not complete 530 # sentences — 'display help information', never 'Display help information.' 531 # (but still capitalise acronyms and proper names) 532 # * Write argument descriptions as verb phrases — 'display x', 'enable y', 533 # 'use z' 534 # * Word descriptions to make it clear when an option expects an argument; 535 # usually this is done with the word 'specify', as in 'specify x' or 536 # 'use specified x') 537 # * Write argument descriptions as tersely as possible — for example, articles 538 # like 'a' and 'the' should be omitted unless it would be confusing 539 # 540 # Other conventions currently used by this function: 541 # 542 # * Order argument specs alphabetically by group name, then option name 543 # * Group options that are directly related, mutually exclusive, or frequently 544 # referenced by other argument specs 545 # * Use only characters in the set [a-z0-9_-] in group names 546 # * Order exclusion lists as follows: short options, long options, groups 547 # * Use American English in descriptions 548 # * Use 'don't' in descriptions instead of 'do not' 549 # * Word descriptions for related options as similarly as possible. For example, 550 # `--foo[enable foo]` and `--no-foo[disable foo]`, or `--foo[use foo]` and 551 # `--no-foo[don't use foo]` 552 # * Word descriptions to make it clear when an option only makes sense with 553 # another option, usually by adding '(with -x)' to the end 554 # * Don't quote strings or variables unnecessarily. When quotes are required, 555 # prefer single-quotes to double-quotes 556 # * Prefix option specs with `$no` when the option serves only to negate the 557 # behaviour of another option that must be provided explicitly by the user. 558 # This prevents rarely used options from cluttering up the completion menu 559 ################################################################################ 560 561 # ------------------------------------------------------------------------------ 562 # Copyright (c) 2011 Github zsh-users - http://github.com/zsh-users 563 # All rights reserved. 564 # 565 # Redistribution and use in source and binary forms, with or without 566 # modification, are permitted provided that the following conditions are met: 567 # * Redistributions of source code must retain the above copyright 568 # notice, this list of conditions and the following disclaimer. 569 # * Redistributions in binary form must reproduce the above copyright 570 # notice, this list of conditions and the following disclaimer in the 571 # documentation and/or other materials provided with the distribution. 572 # * Neither the name of the zsh-users nor the 573 # names of its contributors may be used to endorse or promote products 574 # derived from this software without specific prior written permission. 575 # 576 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 577 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 578 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 579 # DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY 580 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 581 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 582 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 583 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 584 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 585 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 586 # ------------------------------------------------------------------------------ 587 # Description 588 # ----------- 589 # 590 # Completion script for ripgrep 591 # 592 # ------------------------------------------------------------------------------ 593 # Authors 594 # ------- 595 # 596 # * arcizan <ghostrevery@gmail.com> 597 # * MaskRay <i@maskray.me> 598 # 599 # ------------------------------------------------------------------------------ 600 601 # Local Variables: 602 # mode: shell-script 603 # coding: utf-8-unix 604 # indent-tabs-mode: nil 605 # sh-indentation: 2 606 # sh-basic-offset: 2 607 # End: 608 # vim: ft=zsh sw=2 ts=2 et