commit
ebd708b7a4
42
src/_ack
42
src/_ack
|
@ -43,7 +43,9 @@
|
|||
|
||||
|
||||
_ack() {
|
||||
local curcontext="$curcontext" state line cmds update_policy ret=1
|
||||
local context curcontext="$curcontext" state line cmds update_policy ret=1
|
||||
integer NORMARG
|
||||
typeset -A opt_args
|
||||
|
||||
zstyle -s ":completion:${curcontext}:" cache-policy update_policy
|
||||
[[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _ack_types_caching_policy
|
||||
|
@ -54,14 +56,14 @@ _ack() {
|
|||
[[ $#_ack_raw_types -gt 0 ]] && _store_cache "ack-grep" _ack_raw_types
|
||||
fi
|
||||
|
||||
_arguments -C \
|
||||
_arguments -C -s -S -n \
|
||||
'(- 1 *)--version[display version and copyright information]' \
|
||||
'(- 1 *)--help[print a short help statement]' \
|
||||
'(- 1 *)--man[print the manual page]' \
|
||||
'(-a --all -u --unrestricted)'{-a,--all}'[operate on all files, regardless of type (but still skip directories like blib, CVS, etc.)]' \
|
||||
'(-A --after-context -C --context)'{-A,--after-context}'[print N lines of trailing context after matching lines]:number' \
|
||||
'(-B --before-context -C --context)'{-B,--before-context}'[print N lines of leading context before matching lines]:number' \
|
||||
'(-C --context -A --after-context -B --before-context)'{-C,--context}'[print N lines (default 2) of context around matching lines]:number' \
|
||||
'(-A --after-context -C --context)'{-A+,--after-context=}'[print N lines of trailing context after matching lines]:number' \
|
||||
'(-B --before-context -C --context)'{-B+,--before-context=}'[print N lines of leading context before matching lines]:number' \
|
||||
'(-C --context -A --after-context -B --before-context)'{-C-,--context=}'[print N lines (default 2) of context around matching lines]:number' \
|
||||
'(-c --count)'{-c,--count}'[suppress normal output; instead print a count of matching lines for each input file]' \
|
||||
'(--nocolor)--color[highlight the matching text]' \
|
||||
'(--color --color-filename --color-match --color-lineno)--nocolor[supress the color]' \
|
||||
|
@ -75,8 +77,8 @@ _ack() {
|
|||
'-f[only print the files that would be searched, without actually doing any searching]' \
|
||||
'(--nofollow)--follow[follow symlinks]' \
|
||||
'(--follow)--nofollow[don'\''t follow symlinks]' \
|
||||
'-G[only paths matching the given regex are included in the search]:regex' \
|
||||
'-g[print files where the relative path + filename matches the given regex]:regex' \
|
||||
'-G+[only paths matching the given regex are included in the search]:regex' \
|
||||
'-g+[print files where the relative path + filename matches the given regex]:regex' \
|
||||
'(--nogroup)--group[group matches by file name]' \
|
||||
'(--group)--nogroup[do not group matches by file name]' \
|
||||
'(-H --with-filename -h --no-filename)'{-H,--with-filename}'[print the filename for each match]' \
|
||||
|
@ -85,16 +87,16 @@ _ack() {
|
|||
'*--ignore-dir[ignore directory]:directory:_files -/' \
|
||||
'*--noignore-dir[don'\''t ignore directory]:directory:_files -/' \
|
||||
'--invert-file-match[print/search handle files that do not match -g/-G]' \
|
||||
'--line[only print given line of each file]:number' \
|
||||
'--line=[only print given line of each file]:number' \
|
||||
'(-l --files-with-matches -L --files-without-matches)'{-l,--files-with-matches}'[only print the filenames of matching files, instead of the matching text]' \
|
||||
'(-L --files-without-matches -l --files-with-matches)'{-L,--files-without-matches}'[only print the filenames of files that do NOT match]' \
|
||||
'--match[specify the regular expression explicitly]:regex' \
|
||||
'(-m --max-count)'{-m,--max-count}'[stop reading a file after N matches]:number' \
|
||||
'--match=[specify the regular expression explicitly]:regex' \
|
||||
'(-m --max-count)'{-m+,--max-count=}'[stop reading a file after N matches]:number' \
|
||||
'(-r -R --recurse -n --no-recurse)'{-r,-R,--recurse}'[recurse into sub-directories]' \
|
||||
'(-n --no-recurse -r -R --recurse)'{-n,--no-recurse}'[no descending into subdirectories]' \
|
||||
'-o[show only the part of each line matching PATTERN (turns off text highlighting)]:pattern' \
|
||||
'--output[output the evaluation of expr for each line (turns off text highlighting)]:expression' \
|
||||
'--pager[direct ack'\''s output through program]:pager program:_command_names' \
|
||||
'--output=[output the evaluation of expr for each line (turns off text highlighting)]:expression' \
|
||||
'--pager=[direct ack'\''s output through program]:pager program:_command_names' \
|
||||
'--passthru[prints all lines, whether or not they match the expression]' \
|
||||
'--print0[the filenames are output separated with a null byte instead of the usual newline]' \
|
||||
'(-Q --literal)'{-Q,--literal}'[quote all metacharacters in the pattern, it is treated as a literal]' \
|
||||
|
@ -103,7 +105,7 @@ _ack() {
|
|||
'--sort-files[sorts the found files lexically]' \
|
||||
'--show-types[outputs the filetypes that ack associates with each file]' \
|
||||
'--thpppt[display the all-important Bill The Cat logo]' \
|
||||
'*--type[specify the types of files to include or exclude from a search]:type:->types' \
|
||||
'*--type=[specify the types of files to include or exclude from a search]:type:->types' \
|
||||
'*--type-add[files with the given extensions are recognized as being of the given type]:type-def:->type-defs' \
|
||||
'*--type-set[files with the given extensions are recognized as being of the given type]:type-def:->type-defs' \
|
||||
'(-u --unrestricted -a --all)'{-u,--unrestricted}'[all files and directories (including blib/, core.*, ...) are searched, nothing is skipped]' \
|
||||
|
@ -111,13 +113,19 @@ _ack() {
|
|||
'(-w --word-regexp)'{-w,--word-regexp}'[force the given pattern to match only whole words]' \
|
||||
'-1[stops after reporting first match of any kind]' \
|
||||
{'--','--no'}${_ack_raw_types/ ##/\[}']' \
|
||||
'1: :->patterns' \
|
||||
'*: :_files' \
|
||||
'*: :->args' \
|
||||
&& ret=0
|
||||
|
||||
case $state in
|
||||
patterns)
|
||||
_message -e patterns 'pattern' && ret=0
|
||||
args)
|
||||
if [[ CURRENT -eq NORMARG && ${+opt_args[--match]} -eq 0 ]]
|
||||
then
|
||||
# If the current argument is the first non-option argument
|
||||
# and --match isn't present then a pattern is expected
|
||||
_message -e patterns 'pattern' && ret=0
|
||||
else
|
||||
_files
|
||||
fi
|
||||
;;
|
||||
colors)
|
||||
local colors; colors=(
|
||||
|
|
Loading…
Reference in New Issue