diff options
author | Axel Beckert <abe@deuxchevaux.org> | 2018-08-27 13:31:04 +0200 |
---|---|---|
committer | Axel Beckert <abe@deuxchevaux.org> | 2018-08-27 13:31:04 +0200 |
commit | 719a715614f2182a76b30ad27a327d70a86f34f1 (patch) | |
tree | a437eb29da8035bf7c2e30506c08fe6f15719871 /Completion/Unix/Command | |
parent | 7da8d19c224860ae4d6aa3f077fca7f734f20d88 (diff) | |
parent | ef61918398517473b9b594690a3be375f607cebe (diff) | |
download | zsh-719a715614f2182a76b30ad27a327d70a86f34f1.tar.gz zsh-719a715614f2182a76b30ad27a327d70a86f34f1.zip |
Merge tag 'zsh-5.5.1-test-2' into debian
Test release: 5.5.1-test-2.
Diffstat (limited to 'Completion/Unix/Command')
69 files changed, 4354 insertions, 852 deletions
diff --git a/Completion/Unix/Command/_ack b/Completion/Unix/Command/_ack new file mode 100644 index 000000000..626e54e0f --- /dev/null +++ b/Completion/Unix/Command/_ack @@ -0,0 +1,138 @@ +#compdef ack ack2 ack-grep ack-standalone + +local curcontext="$curcontext" update_policy ign suf ret=1 +local -a state line +local -A opt_args + +_ack_types_caching_policy() { + # Rebuild if ackrc more recent than cache. + [[ -f ${ACKRC:-$HOME/.ackrc} && ${ACKRC:-$HOME/.ackrc} -nt "$1" ]] && return 0 + + # Rebuild if cache is older than one week. + local -a oldp + oldp=( "$1"(Nmw+1) ) + (( $#oldp )) && return 0 + + return 1 +} + +zstyle -s ":completion:${curcontext}:" cache-policy update_policy +[[ -z "$update_policy" ]] && zstyle ":completion:${curcontext}:" cache-policy _ack_types_caching_policy + +typeset -ga _ack_raw_types +if _cache_invalid ack-types || ! _retrieve_cache ack-types; then + (( ${+commands[${words[1]}]} )) && _ack_raw_types=( + ${(S)${(S)${(f)${${"$(_call_program file-types $words[1] --help=types)"}#*--\[no\]}}%; first line matches \/*\/}#*no\]} ) + [[ $#_ack_raw_types -gt 0 ]] && _store_cache ack-types _ack_raw_types +fi + +(( $#words > 2 )) && ign='!' + +_arguments -C -s -S \ + '(-i --ignore-case --smart-case --no-smart-case --nosmart-case --lines)'{-i,--ignore-case}'[match case-insensitively]' \ + '(-i --ignore-case --no-smart-case --nosmart-case --lines)--smart-case[case-insensitive match unless pattern includes uppercase]' \ + '(-i --ignore-case --smart-case --no-smart-case --nosmart-case --lines)'{--no-smart-case,--nosmart-case}'[disable --smart-case option]' \ + '(-v --invert-match)'{-v,--invert-match}'[select non-matching lines]' \ + '(-w --word-regexp)'{-w,--word-regexp}'[force pattern to match only whole words]' \ + '(-Q --literal)'{-Q,--literal}'[use literal strings]' \ + '(1)*--lines=[only print specific lines of each file]:line number (list and/or range)' \ + '(-l --files-with-matches -L --files-without-matches)'{-l,--files-with-matches}"[output matching files' names only]" \ + '(-L --files-without-matches -l --files-with-matches)'{-L,--files-without-matches}"[output non-matching files' names only]" \ + '--output=[output result of expression for each line (turns off text highlighting)]:perl expression' \ + '-o[show only matching part of line]' \ + '--passthru[print all lines, whether matching or not]' \ + '(1)--match=[specify the pattern explicitly]:pattern' \ + '(-m --max-count)'{-m+,--max-count=}'[stop after specified no of matches in each file]:max number of matches' \ + '-1[stop after reporting first match of any kind]' \ + '(-H --with-filename -h --no-filename)'{-H,--with-filename}'[print filename with each match]' \ + '(-h --no-filename -H --with-filename)'{-h,--no-filename}'[suppress printing of filenames]' \ + '(-c --count)'{-c,--count}'[only print a count of matching lines]' \ + '--column[print column number of first match on each line]' \ + '(-A --after-context -C --context)'{-A+,--after-context=}'[specify lines of trailing context]::lines [2]' \ + '(-B --before-context -C --context)'{-B+,--before-context=}'[specify lines of leading context]::lines [2]' \ + '(-C --context -A --after-context -B --before-context)'{-C+,--context=}'[specify lines of context]:lines [2]' \ + '--print0[separate filenames with a null instead of a newline]' \ + '-s[suppress error messages about nonexistent or unreadable files]' \ + "(--nopager)--pager=[direct ack's output through program]: : _command_names -e" \ + "(--pager)--nopager[don't send output through a pager; overrides .ackrc, ACK_PAGER & ACK_PAGER_COLOR]" \ + '(--noheading --heading)'{--noheading,--heading}'[print a filename heading above results, default on]' \ + '(--nobreak --break)'{--nobreak,--break}'[print a break between results from different files, default on]' \ + '(--nogroup)--group[group matches by file name]' \ + "(--group)--nogroup[don't group matches by file name]" \ + '(--nocolor --nocolour)--colo'{,u}'r[enable color highlighting of output]' \ + '(--color --colour --color-filename --color-match --color-lineno)--nocolo'{,u}'r[suppress the color]' \ + '(--nocolor --nocolour --color --colour)--color-filename=[sets the color to be used for filenames]:color:->colors' \ + '(--nocolor --nocolour --color --colour)--color-match=[sets the color to be used for matches]:color:->colors' \ + '(--nocolor --nocolour --color --colour)--color-lineno=[specify color for line numbers]:color:->colors' \ + '--flush[flush output on every line]' \ + '(1)-f[only print the files that would be searched, without actually doing any searching]' \ + '(1)-g[print files where the relative path + filename matches the given pattern]:pattern to match against filenames' \ + '--sort-files[sorts the found files lexically]' \ + '--show-types[print the file types that ack associates with each file]' \ + '(--files-from -x)--files-from=[read the list of files to search from specified file]:files:_files' \ + '(-x --files-from)-x[read the list of files to search from standard input]' \ + '*--ignore-dir'{,ectory}'=[ignore directory]:directory:_directories' \ + '*--noignore-dir'{,ectory}'=[remove directory from ignored list]:directory:_directories' \ + '*--ignore-file=[add filter for ignoring files]:filter:->filters' \ + '(-r -R --recurse -n --no-recurse)'{-r,-R,--recurse}'[recurse subdirectories]' \ + '(-n --no-recurse -r -R --recurse)'{-n,--no-recurse}"[don't descend into subdirectories]" \ + '(--nofollow)--follow[follow symlinks]' \ + "(--follow)--nofollow[don't follow symlinks]" \ + '(-k --known-types)'{-k,--known-types}'[include only files of types that ack recognizes]' \ + '*--type=[specify the types of files to include or exclude from a search]:type:->file-types' \ + '*--type-'{add,set}'=[files with the given extensions are recognized as being of the given type]:type-def:->type-defs' \ + '*--type-del=[remove all filters associated with specified file type]: :->file-types' \ + '(--env)--noenv[ignore environment variables and global ackrc files]' '!(--noenv)--env)' \ + '--ackrc=[specify an ackrc file to use]:files:_files' \ + '--ignore-ack-defaults[ignore default definitions included with ack]' \ + "${ign}(- 1 *)--create-ackrc[output an ackrc based on customizations]" \ + "${ign}(- 1 *)"{-\?,--help}'[display usage information]' \ + "${ign}(- 1 *)--help-types[display all known types]" \ + "${ign}(- 1 *)--dump[display information on which options are loaded and which RC files]" \ + '(--filter --nofilter)--filter[treat standard input as pipe]' \ + '(--filter --nofilter)--nofilter[treat standard input as tty]' \ + "${ign}(- 1 *)--man[display the manual page]" \ + "${ign}(- 1 *)--version[display version and copyright information]" \ + "${ign}(- 1 *)--bar[consult Admiral Ackbar]" \ + "${ign}(- 1 *)--thpppt[bill the cat]" \ + "${ign}(- 1 *)--cathy[chocolate chocolate chocolate]" \ + {'--','--no'}${_ack_raw_types/ ##/\[}']' \ + '1: :_guard "^-*" pattern' \ + '*:file:_files' && ret=0 + +case $state in + colors) + compset -P '* ' + compset -S ' *' + _wanted colors expl color compadd \ + {,on_}{,bright_}{black,red,green,yellow,blue,magenta,cyan,white} \ + clear reset dark bold under{line,score} blink reverse concealed && ret=0 + ;; + type-defs) + if ! compset -P 1 '*:'; then + _message -e type-name 'type name' + return + fi + ;& # fall-through + filters) + if compset -P 1 'ext:'; then + _sequence _wanted extensions expl 'extension' compadd - *.*(N:e) && ret=0 + elif compset -P 1 'is:'; then + _description files expl 'file name' + _files "$expl[@]" && ret=0 + elif compset -P 1 '(firstline|)match:'; then + _message -e patterns 'pattern' + else + compset -S ':*' || suf=-S + _description filters expl filter + compadd "$expl[@]" ${suf:+-S:} ext is && ret=0 + compadd "$expl[@]" ${suf:+-S:/} match firstlinematch && ret=0 + fi + ;; + file-types) + local types; types=( {,no}${^_ack_raw_types/ ##/:} ) + _describe -t file-types 'file type' types && ret=0 + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_ansible b/Completion/Unix/Command/_ansible index f05dac8a6..330ef66b7 100644 --- a/Completion/Unix/Command/_ansible +++ b/Completion/Unix/Command/_ansible @@ -30,7 +30,7 @@ case $service in '(-D --diff)'{-D,--diff}'[show differences when changing small files and templates]' '(-b --become)'{-b,--become}'[escalate privileges on remote system]' '(-f --forks)'{-f+,--forks=}'[specify number of parallel processes to use]:processes [5]' - '--become-method=[specify privilege escalation method to use]:method [sudo]:(sudo su pbrun pfexec doas dzdo ksu runas pmrun)' + '--become-method=[specify privilege escalation method to use]:method [sudo]:(sesu sudo su pbrun pfexec doas dzdo ksu runas pmrun enable)' '--become-user=[specify remote user for running operations]:user:_users' "--syntax-check[perform a syntax check on the playbook, but don't execute it]" '!(-R --su-user -U --sudo-user)'{-R,-U,--su-user,--sudo-user}':user [root]:_users' @@ -39,17 +39,20 @@ case $service in ansible|ansible-console|ansible-inventory|ansible-playbook|ansible-pull|ansible-vault) args+=( '--ask-vault-pass[ask for vault password]' - '--new-vault-id=[specify new vault identity to use for rekey]:vault id' - '--new-vault-password-file=[specify new vault password file to use for rekey]:file:_files' '--vault-id=[specify vault identity to use]:vault identity' '--vault-password-file=[specify vault password file]:vault password file:_files' ) ;| ansible|ansible-console|ansible-inventory|ansible-playbook|ansible-pull) args+=( - '--list-hosts[output list of matching hosts]' - '(-i --inventory)'{-i+,--inventory=}'[specify inventory host file]:inventory file:_files' + '(-i --inventory)'{-i+,--inventory=}'[specify inventory host file or host list]: : _alternative "files\:inventory file\:_files" + "hosts\:host\: _sequence _hosts"' '!(-i --inventory)--inventory-file=:inventory file:_files' + ) + ;| + ansible|ansible-console|ansible-playbook|ansible-pull) + args+=( + '--list-hosts[output list of matching hosts]' '(-l --limit)'{-l+,--limit=}'[further limit hosts to an additional pattern]:host subset:->hosts' ) ;| @@ -58,21 +61,22 @@ case $service in '(-e --extra-vars)'{-e+,--extra-vars=}'[set additional variables]:key=value or YAML/JSON' ) ;| - ansible-playbook|ansible-pull) + ansible|ansible-console|ansible-inventory) args+=( - '(-t --tags)'{-t,--tags}'[only run plays and tasks tagged with these values]' - "--skip-tags[only run plays and tasks whose tags don't match]" + '--playbook-dir=[specify substitute playbook directory]:directory:_directories' ) ;| - ansible|ansible-pull) + ansible-playbook|ansible-pull) args+=( - '(-m --module-name)'{-m+,--module-name=}'[specify module]:module:->plugins' + '(-t --tags)'{-t,--tags}'[only run plays and tasks tagged with these values]' + "--skip-tags[only run plays and tasks whose tags don't match]" ) ;| ansible) args+=( '(-a --args)'{-a+,--args=}'[specify command or module arguments]:arguments:->args' '(-B --background)'{-B+,--background=}'[run asynchronously, failing after specified time]:fail timeout (seconds)' + '(-m --module-name)'{-m+,--module-name=}'[specify module]:module:->plugins' '(-o --one-line)'{-o,--one-line}'[condense output]' '(-P --poll)'{-P+,--poll=}'[specify the poll interval if using -B]:interval (seconds) [15]' '(-t --tree)'{-t+,--tree=}'[specify directory for log output]:directory:_directories' @@ -98,14 +102,16 @@ case $service in ;; ansible-doc) args+=( - '(-l --list)'{-l,--list}'[list available plugins]' - '(-s --snippet)'{-s,--snippet}'[show playbook snippet for specified plugins]' + '(-l --list -F --list_files -s --snippet)'{-l,--list}'[list available plugins]' + '(-l --list -F --list_files -s --snippet)'{-F,--list_files}'[show plugin names and their source files without summaries]' + '(-l --list -F --list_files -s --snippet)'{-s,--snippet}'[show playbook snippet for specified plugins]' '(-t --type)'{-t+,--type=}'[choose plugin type]:plugin type [module]:(cache callback connection inventory lookup module strategy vars)' '*:plugin:->plugins' ) ;; ansible-inventory) args+=( + '--export[when doing an --list, represent in a way that is optimized for export]' '(-y --yaml)--graph[output inventory graph]' '--host[output specific host information]' '--list[output all hosts information]' @@ -125,7 +131,7 @@ case $service in ;; ansible-playbook) args+=( - '--flush-cache[clear the fact cache]' + '--flush-cache[clear the fact cache for every host in inventory]' '--force-handlers[run handlers even if a task fails]' '--list-tags[list all available tags]' '--list-tasks[list all tasks that would be executed]' @@ -139,6 +145,7 @@ case $service in "--check[don't make any changes]" '(-d --directory)'{-d+,--directory=}'[specify directory to checkout repository to]:directory:_directories' '--full[do a full instead of a shallow clone]' + '(-m --module-name)'{-m+,--module-name=}'[specify repository module used for checking out repository]:module:(git subversion hg bzr)' '--accept-host-key[adds the hostkey for the repo url if not already added]' '--purge[purge checkout after playbook run]' '(-f --force)'{-f,--force}'[run the playbook even if the repository could not be updated]' @@ -153,6 +160,8 @@ case $service in ;; ansible-vault) args=( -A "-*" $args + '--new-vault-id=[specify new vault identity to use for rekey]:vault id' + '--new-vault-password-file=[specify new vault password file to use for rekey]:file:_files' '*::args:->vault' ) ;; @@ -200,9 +209,15 @@ case $state in plugins) plugvar=_ansible_${plug}_plugins typeset -ga ${plug} - (( ${(P)#plugvar} )) || set -A ${plugvar} \ - ${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}/ ##/:} - _describe -t plugins "${plug} plugin" $plugvar && ret=0 + if zstyle -T ":completion:${curcontext}:plugins" verbose; then + (( ${(P)#plugvar} )) || set -A ${plugvar} \ + ${${(f)"$(_call_program plugins ansible-doc -t $plug -l)"}/ ##/:} + _describe -t plugins "${plug} plugin" $plugvar && ret=0 + else + (( ${(P)#plugvar} )) || set -A ${plugvar} \ + ${${(f)"$(_call_program plugins ansible-doc -t $plug -F)"}%% *} + _wanted plugins expl "${plug} plugin" compadd -a $plugvar && ret=0 + fi ;; galaxy) curcontext="${curcontext%:*}-${line[1]}:" @@ -265,6 +280,11 @@ case $state in curcontext="${curcontext%:*}-${line[1]}:" args=() case $line[1] in + encrypt*|edit|rekey) + args+=( + '--encrypt-vault-id=[specify vault id to use to encrypt (required if more than one vault-id is provided)]:vault id' + ) + ;| (de|en)crypt*) args=( '--output=[specify output file name]:file:_files' ) ;| encrypt_string) args+=( diff --git a/Completion/Unix/Command/_arp b/Completion/Unix/Command/_arp index 5b047b2b8..90e30d6c2 100644 --- a/Completion/Unix/Command/_arp +++ b/Completion/Unix/Command/_arp @@ -37,7 +37,7 @@ case $OSTYPE in flags+=( netmask ) ;; darwin*|freebsd*|dragonfly*) - cmds+=( '(-n -v -i)-S[create an arp entry, replacing any existing entry]' ) + cmds+=( '(-n -i)-S[create an arp entry, replacing any existing entry]' ) ;| darwin*|freebsd*) args+=( '(-s -Q -f)-i+[select an interface]:interface:_net_interfaces' ) @@ -58,7 +58,6 @@ case $OSTYPE in args+=( $vopt ) ;; freebsd*) - args+=( $vopt ) flags+=( blackhole reject ) ;; openbsd*) diff --git a/Completion/Unix/Command/_base64 b/Completion/Unix/Command/_base64 new file mode 100644 index 000000000..47a650343 --- /dev/null +++ b/Completion/Unix/Command/_base64 @@ -0,0 +1,59 @@ +#compdef base64 gbase64 base32 gbase32 + +# Note: This does NOT cover `uuencode`/`uudecode`, which on some BSD systems +# have the aliases `b64encode`/`b64decode` — those are sufficiently different +# that they belong in another function. It DOES cover GNU's `base32`, since it +# is essentially the same program as their `base64`. + +local variant type=base${service//[^2346]/} + +_pick_variant -r variant \ + gnu='Free Soft' fourmilab=fourmi darwin=-D unix --version + +case $variant in + gnu) + _arguments -s -S : \ + '(: -)--help[display help information]' \ + '(: -)--version[display version information]' \ + + dec \ + '(enc -d --decode)'{-d,--decode}"[decode input from $type]" \ + '(enc -i --ignore-garbage)'{-i,--ignore-garbage}'[ignore irrelevant characters when decoding]' \ + + '(enc)' \ + '(dec)'{-w+,--wrap=}'[wrap encoded lines at specified number of columns]:number of columns' \ + + in \ + '1:input file:_files' + return + ;; + darwin) + _arguments -s -S : \ + '(: -)'{-h,--help}'[display help information]' \ + + '(dec)' \ + '(enc)'{-D,--decode}"[decode input from $type]" \ + + '(enc)' \ + '(dec)'{-b+,--break=}'[wrap encoded lines at specified number of columns]:number of columns' \ + + '(out)' \ + {-o+,--output=}'[specify output file]:output file:_files' \ + + '(in)' \ + {-i+,--input=}'[specify input file]:input file:_files' \ + '1:input file:_files' + return + ;; + fourmilab) + _arguments -s -S : \ + '(: -)--copyright[display copyright information]' \ + '(: -)'{-u,--help}'[display help information]' \ + '(: -)--version[display version information]' \ + + dec \ + '(enc -d --decode)'{-d,--decode}"[decode input from $type]" \ + '(enc -n --noerrcheck)'{-n,--noerrcheck}'[ignore errors when decoding]' \ + + '(enc)' \ + '(dec)'{-e,--encode}"[encode input to $type]" \ + + io \ + '1:input file:_files' \ + '2:output file:_files' + return + ;; +esac + +# A few other implementations exist, though they are rarely encountered +_default diff --git a/Completion/Unix/Command/_bash b/Completion/Unix/Command/_bash new file mode 100644 index 000000000..cc219f788 --- /dev/null +++ b/Completion/Unix/Command/_bash @@ -0,0 +1,85 @@ +#compdef bash + +local ret=1 +local -a context line state state_descr args tmp cmd +local -A opt_args val_args + +cmd=( $words[1] --noprofile --norc ) + +args=( + # Long options must appear before short options (take care — some of these are + # duplicated in the s group below!) + + l + '!--debug' + '--debugger[enable extended debugging mode]' + '(-D --dump-po-strings --dump-strings)--dump-po-strings[like -D, but display in gettext PO format]' + '(-D --dump-po-strings --dump-strings)--dump-strings[display strings subject to language translation]' + '(: -)--help[display help information]' + # The usual = is deliberately omitted here + '(--init-file --rcfile)'{--init-file,--rcfile}'[load specified file instead of ~/.bashrc]: :_files' + '(-l --login)--login[act as login shell]' + '--noediting[disable readline editing]' + '--noprofile[do not load /etc/profile, ~/.bash_profile, etc.]' + '--norc[do not load ~/.bashrc]' + '--posix[enable POSIX mode]' + '(-r --restricted)--restricted[act as restricted shell]' + '(: -)--version[display version information]' + # This is ugly, but this way the + variants have accurate descriptions. Note + # that bash does accept + variants of -i, -l, -s, etc., but they don't seem to + # actually do anything, so we don't bother with them + + s + '(l)'{'-a[','+a[do not '}'mark all functions and variables for export]' + '(l)'{'-B[','+B[do not '}'enable brace expansion]' + '(l)'{'-b[','+b[do not '}'report status of terminated background jobs immediately]' + '(l)'{'-C[','+C[do not '}'prevent output redirection from overwriting existing files]' + '(l 1 -)-c[execute specified command string]:command string:_cmdstring:argv[0]:' + '(l)-D[display strings subject to language translation]' + '(l)'{'-E[','+E[do not '}'make functions and subshells inherit ERR traps]' + '(l)'{'-e[','+e[do not '}'exit immediately on non-zero return]' + '(l)'{'-f[','+f[do not '}'disable file globbing]' + '(l)'{'-H[','+H[do not '}'enable history substitution]' + '(l)'{'-h[','+h[do not '}'hash commands]' + '(l)-i[act as interactive shell]' + '(l)'{'-k[','+k[do not '}'act on variable assignments in command arguments]' + '(l)-l[act as login shell]' + '(l)'{'-m[','+m[do not '}'enable job control]' + '(l)'{'-n[','+n[do not '}'read (syntax-check) commands only]' + '(l)*'{'-O[','+O[un'}'set specified `shopt` option]: :->shopt-options' + '(l)*'{'-o[','+o[un'}'set specified `set` option]: :->set-options' + '(l)'{'-P[','+P[do not '}'resolve cd paths]' + '(l)'{'-p[','+p[do not '}'enable privileged mode]' + '(l)-r[act as restricted shell]' + '(l 1 -c)-s[read commands from standard input]' + '(l)'{'-T[','+T[do not '}'make functions and subshells inherit DEBUG and RETURN traps]' + '(l)'{'-t[','+t[do not '}'exit after executing one command]' + '(l)'{'-u[','+u[do not '}'treat unset variables as an error during parameter expansion]' + '(l)'{'-v[','+v[do not '}'print shell input lines as they are read]' + '(l)'{'-x[','+x[do not '}'print command trace]' + + o + '(-)1:script file:_files' + '(-)*:: :->args' +) + +_arguments -s -S -A '-*' : $args && ret=0 + +case $state in + args) + if [[ -n ${opt_args[(i)s--[cs]]} ]]; then + _files && ret=0 + else + _normal && ret=0 + fi + ;; + set-options) + tmp=( ${(f)"$( _call_program set-options $cmd -c '"shopt -o"' )"} ) + tmp=( ${tmp%%[[:space:]]*} ) + _values -w '`set` option' $tmp && ret=0 + ;; + shopt-options) + tmp=( ${(f)"$( _call_program shopt-options $cmd -c shopt )"} ) + tmp=( ${tmp%%[[:space:]]*} ) + _values -w '`shopt` option' $tmp && ret=0 + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_chroot b/Completion/Unix/Command/_chroot new file mode 100644 index 000000000..516992694 --- /dev/null +++ b/Completion/Unix/Command/_chroot @@ -0,0 +1,53 @@ +#compdef chroot gchroot + +local variant ret=1 +local -a context line state state_descr args +local -A opt_args + +_pick_variant -r variant gnu='Free Soft' unix --version + +variant+=-$OSTYPE + +case $variant in + gnu-*) + args=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' + '--groups=[specify supplemental group memberships]: :_sequence -s , _groups' + '--userspec=[specify user and group to run process as]: :->userspecs' + '--skip-chdir[do not change working directory to /]' + ) + ;; + *-openbsd*) + args=( + '-u+[specify user to run process as]: :_users' + '-g+[specify group to run process as, and supplemental group memberships]: :_sequence -s , _groups' + ) + ;; + *-(darwin|dragonfly|freebsd|netbsd)*) + args=( + '-u+[specify user to run process as]: :_users' + '-g+[specify group to run process as]: :_groups' + '-G+[specify supplemental group memberships]: :_sequence -s , _groups' + ) + ;; +esac + +args+=( '1:new root directory:_directories' '*:::command:_normal' ) + +_arguments -s -S : $args && ret=0 + +# @todo user:group specs are probably used often enough to justify making a type +# function for this (see also `chown`, `cpio`, `rsync`, ...) +[[ $state == userspecs ]] && +if compset -P '*:*:'; then + ret=1 +elif compset -P '*:'; then + _groups && ret=0 +elif compset -S ':*'; then + _users && ret=0 +else + _users -qS : && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_cksum b/Completion/Unix/Command/_cksum new file mode 100644 index 000000000..bb2f60ac7 --- /dev/null +++ b/Completion/Unix/Command/_cksum @@ -0,0 +1,112 @@ +#compdef cksum gcksum sum gsum md2 md4 md5 rmd160 sha1 sha256 sha384 sha512 sha512t256 skein256 skein512 skein1024 + +# This function covers mostly the BSD `cksum`, `sum`, and digest utilities. It +# also covers the GNU Coreutils `cksum` and `sum`. For the GNU digest utilities, +# see `_md5sum`. For the `shasum` Perl script, see `_shasum`. +# +# Notes: +# - We really don't do a very good job of handling option exclusivity here. In +# particular, OpenBSD treats -t and -x as exclusive of each other and most +# other options — but there are issues with other variants too (@todo) +# - Although only OpenBSD's documentation mentions it, -t can be supplied +# multiple times with all variants to run additional rounds of testing +# - All digest variants on a given platform share code, but not all variants are +# found on all platforms (e.g., Darwin only has `md5`). Some BSDs are actively +# purging legacy/insecure digest tools +# - The documentation for Dragonfly/FreeBSD `sum` says that it's 'identical to' +# `cksum`, but, as the synopsis confirms, it doesn't take any options +# - FreeBSD's -c is never useful, and Dragonfly's -b/-e are *almost* never +# useful, with multiple input files +# - NetBSD's -n isn't useful with `sum` and `cksum` unless a digest is specified +# with -a. Similarly, OpenBSD's -b isn't useful with `cksum` without -a +# - OpenBSD's -a option allows you to add a b/x suffix to each algorithm name; +# we don't handle that. Also, only one -a option can be used in conjunction +# with -c; we don't handle that either + +local -a args + +_pick_variant gnu='Free Soft' unix --version && { + args=( + '*: :_files' + '(: -)--help[display help information]' + '(: -)--version[display version information]' + ) + [[ $service == *cksum* ]] || args+=( + '(-s --sysv)-r[use BSD algorithm (1 KiB blocks)]' + '(-r -s --sysv)'{-s,--sysv}'[use System V algorithm (512 B blocks)]' + ) + _arguments -s -S : $args + return +} + +[[ $OSTYPE == (darwin|dragonfly|freebsd|openbsd)* && $service == sum ]] && { + _default + return +} + +[[ $OSTYPE == (darwin|dragonfly|freebsd)* && $service == cksum ]] && { + _arguments -s -S -A '-*' \ + '-o[use specified historic algorithm]:historic algorithm:(1 2 3)' \ + '*: :_files' + return +} + +case $OSTYPE in + darwin*|dragonfly*|freebsd*|netbsd*) + args+=( + '(-n -p -r)-q[output checksums only]' + ) + ;| # MATCH AGAIN + darwin*|dragonfly*|freebsd*|openbsd*) + args+=( + '(-p -q)-r[reverse output format]' + ) + ;| # MATCH AGAIN + netbsd*|openbsd*) + args+=( + '-c[verify checksums from input files]' + ) + ;| # MATCH AGAIN + dragonfly*) + args+=( + '-b+[begin processing files at specified offset]:begin offset (bytes)' + '-e+[end processing files at specified offset]:end offset (bytes)' + ) + ;; + freebsd*) + args+=( + '-c+[verify input against specified digest string]:digest string' + ) + ;; + netbsd*) + args+=( + '(-p -q)-n[reverse output format]' + '(-p)-w[warn on malformed checksum files]' + ) + [[ $service == (|ck)sum ]] && args+=( + '(-o)-a+[use specified algorithm]:algorithm:(crc md2 md4 md5 old1 old2 rmd160 sha1 sha256 sha384 sha512)' + '(-a)-o+[use specified historic algorithm]:historic algorithm:(1 2)' + ) + ;; + openbsd*) + args+=( + '-b[output in base64]' + '(-h)-C+[verify input files against checksums in specifed file]:checksum file:_files' + '(-C)-h+[output checksums to specified file]:checksum file:_files' + '(-n -r)-q[output checksum only, or suppress check success messages]' + ) + [[ $service == cksum ]] && args+=( + '*-a+[use specified algorithm(s)]:algorithm:_values -s , algorithm cksum md5 rmd160 sha1 sha224 sha256 sha384 sha512/256 sha512' + ) + ;; +esac + +args+=( + '-p[output stdin along with checksum]' + '*-s+[checksum specified string]:string' + '*-t[run built-in time trial(s)]' + '-x[run built-in tests]' + '*: :_files' +) + +_arguments -s -S -A '-*' : $args diff --git a/Completion/Unix/Command/_comm b/Completion/Unix/Command/_comm index d1d835f6a..f8c535a44 100644 --- a/Completion/Unix/Command/_comm +++ b/Completion/Unix/Command/_comm @@ -1,6 +1,6 @@ #compdef comm gcomm -local -a args +local -a args aopts=( -A '-*' ) args=( '-1[suppress lines unique to first file]' @@ -11,10 +11,13 @@ args=( ) if _pick_variant gnu=GNU unix --version; then + aopts=( ) args+=( '(--nocheck-order)--check-order[check input is correctly sorted]' "(--check-order)--nocheck-order[don't check input is correctly sorted]" - '--output-delimiter=:delimiter' + '--output-delimiter=[specify column delimiter]:delimiter' + '--total[display summary]' + '(-z --zero-terminated)'{-z,--zero-terminated}'[use NUL as line delimiter]' '(- : *)--version[display version information]' '(- : *)--help[display help information]' ) @@ -24,4 +27,4 @@ elif [[ $OSTYPE = (openbsd|netbsd)* ]]; then args+=( '-f[case insensitive comparison of lines]' ) fi -_arguments -s $args +_arguments -s -S $aopts : $args diff --git a/Completion/Unix/Command/_crontab b/Completion/Unix/Command/_crontab new file mode 100644 index 000000000..cda7549a1 --- /dev/null +++ b/Completion/Unix/Command/_crontab @@ -0,0 +1,68 @@ +#compdef crontab + +# Notes: +# - We assume a cronie-, dcron-, or Vixie-esque crontab +# - BusyBox crontab is forked from dcron +# - Generally only the super-user can use -c/-u; we aren't that restrictive +# - @todo As usual, BusyBox multi-call isn't handled + +local variant sluser +local -a args etargs ccargs clargs rcargs aopts + +_pick_variant -r variant \ + dcron='-c*(#i)dir' \ + cronie-selinux='(#i)selinux' \ + cronie='(#i)cluster' \ + unix --help +variant+=-$OSTYPE + +# On Solaris, instead of using -u, the user can be specified as an optional +# first operand with -e/-l/-r. We'll treat it as an optional *argument* to one +# of those options, though, since the logic is a bit simpler +if [[ $variant == *-solaris* ]]; then + sluser='::user whose crontab to work with:_users' +else + etargs+=( '(cl)-u+[specify user whose crontab to work with]: :_users' ) +fi + +case $variant in + dcron-*) + etargs+=( '-c+[specify crontab directory]:crontab directory:_directories' ) + ;; + cronie-selinux-*) + ccargs+=( '(-l cl nc rc)-s[append SELinux context (with -e)]' ) + ;& # FALL THROUGH + cronie-*) + etargs+=( '(: * -)-V[display version information]' ) + clargs+=( + '(: * -)-c[display cluster host]' + '(: * -)-n+[specify cluster host]: :_hosts' + ) + ;& # FALL THROUGH + *-linux*) + rcargs+=( '(cc cl nc)-i[prompt for confirmation (with -r)]' ) + ;; + *-freebsd*) + rcargs+=( '(cc cl nc)-f[bypass confirmation prompt (with -r)]' ) + ;; +esac + +(( $#etargs )) && args+=( + et $etargs ) # Misc. +(( $#clargs )) && args+=( + cl $clargs ) # Work with cluster +args+=( + + nc # Install new crontab + '(cc cl rc sl):crontab to install:_files' + + cc # Edit/display current crontab + "(-l cl nc rc)-e[edit current crontab]$sluser" + "(-e -s cl nc rc)-l[display current crontab]$sluser" + $ccargs + + rc # Remove current crontab + "(cc cl nc)-r[remove current crontab]$sluser" + $rcargs +) + +# Implementations that use GNU's getopt(3) probably support permutation; this +# should be accurate enough +[[ $OSTYPE == linux* ]] || aopts=( -A '-*' ) + +_arguments -s -S $aopts : $args diff --git a/Completion/Unix/Command/_dd b/Completion/Unix/Command/_dd index e51337f21..e5c5e63ce 100644 --- a/Completion/Unix/Command/_dd +++ b/Completion/Unix/Command/_dd @@ -1,17 +1,99 @@ #compdef dd gdd -_values -w 'option' \ - 'if[specify input file]:input file:_tilde_files' \ - 'of[specify output file]:output file:_tilde_files' \ - '(bs)ibs[input block size]:block size (bytes)' \ - '(bs)obs[output block size]:block size (bytes)' \ - '(ibs obs)bs[block size]:block size (bytes)' \ - 'cbs[conversion buffer size]:buffer size (bytes)' \ - 'skip[input blocks initially skipped]:blocks' \ - 'seek[output blocks initially skipped]:blocks' \ - 'files[specify number of input files to copy and concatenate]:number of files' \ - 'count[number of input blocks to copy]:blocks' \ - 'conv[specify conversions to apply]:conversion:_values -s , conversion - "(ebcdic ibm)ascii" "(ascii ibm)ebcdic" "(ascii ebcdic)ibm" - "(unblock)block" "(block)unblock" - "(ucase)lcase" "(lcase)ucase" swab noerror sync' +local -a vals conv flags +local variant + +_pick_variant -r variant gnu=GNU $OSTYPE --version + +vals=( + '(ibs obs)bs[block size]:block size (bytes)' + 'cbs[conversion buffer size]:buffer size (bytes)' + 'conv[specify conversions to apply]: :_values -s , conversion $conv' + 'count[number of input blocks to copy]:blocks' + '(bs)ibs[input block size]:block size (bytes)' + 'if[specify input file]:input file:_tilde_files' + '(bs)obs[output block size]:block size (bytes)' + 'of[specify output file]:output file:_tilde_files' + 'seek[output blocks initially skipped]:blocks' + 'skip[input blocks initially skipped]:blocks' +) +conv=( + '(ascii asciib oldascii ebcdic ebcdicb oldebcdic ibm ibmb oldibm)'{ascii,ebcdic,ibm} + '(unblock)block' '(block)unblock' + '(ucase)lcase' '(lcase)ucase' + swab sync noerror notrunc +) + +case $variant in + ^gnu) + vals+=( + 'files[specify number of input files to copy and concatenate]:number of files' + ) + ;| + (gnu|darwin|dragonfly|(free|net)bsd*) + conv+=( sparse ) + ;| + gnu|netbsd*) + vals+=( + '*iflag[specify read flags]:flag:_sequence compadd - $flags' + '*oflag[specify write flags]:flag:_sequence compadd - $flags' + ) + flags=( append direct directory dsync sync nonblock noctty nofollow ) + ;| + darwin*|dragonfly*|(free|net)bsd*) + vals+=( + 'oseek[output blocks initially skipped]:blocks' + ) + conv+=( + '(ascii oldascii ebcdic oldebcdic oldibm)'old{ascii,ebcdic,ibm} + ) + ;| + (darwin|dragonfly|freebsd|netbsd|solaris)*) + vals+=( + 'iseek[input blocks initially skipped]:blocks' + ) + ;| + (open|free)bsd*) + vals+=( + 'status[specify level of information to print to stderr]:level:(none noxfer)' + ) + conv+=( osync ) + ;| + + freebsd*) + vals+=( + 'fillchar[specify padding character]:character' + 'speed[limit copying speed]:speed (bytes/second)' + ) + conv+=( + '(pareven parnone parodd parset)'{pareven,parnone,parodd,parset} + ) + ;; + gnu) + vals+=( + 'status[specify level of information to print to stderr]:level:(none noxfer progress)' + ) + flags+=( fullblock noatime nocache count_bytes skip_bytes seek_bytes ) + conv+=( excl nocreat fdatasync fsync ) + ;; + netbsd*) + vals+=( + 'msgfmt[specify format for information summary]:format:(quiet posix human)' + 'progress[enable progress display]:enable:(1)' + ) + flags+=( + wronly rdwr creat trunc excl shlock exlock cloexec nosigpipe rsync alt_io async + ) + ;; + solaris*) + vals+=( + 'files[specify number of input files to copy and concatenate]:number of files' + 'oseek[output blocks initially skipped (via seek, not NUL-padding)]:blocks' + ) + conv+=( + '(ascii asciib ebcdic ebcdicb ibmb)'{ascii,ebcdic,ibm}b + ) + ;; +esac + +_values -w 'option' $vals diff --git a/Completion/Unix/Command/_df b/Completion/Unix/Command/_df index 2586f4358..a31145cd4 100644 --- a/Completion/Unix/Command/_df +++ b/Completion/Unix/Command/_df @@ -28,32 +28,63 @@ if _pick_variant gnu=GNU unix --version; then {-H,--si}'[human readable format, but use powers of 1000 not 1024]' {-i,--inodes}'[list inode information instead of block usage]' ) -elif [[ "$OSTYPE" == (darwin|freebsd|dragonfly)* ]]; then +elif [[ "$OSTYPE" == (darwin|dragonfly|freebsd|netbsd*|openbsd)* ]]; then args=( - '(-b -g -H -h -k -m)-b[use 512-byte blocks (default)]' - '(-b -g -H -h -k -m)-g[use 1024^3-byte blocks]' - '(-b -g -H -h -k -m)-H[human-readable output (base 10)]' - '(-b -g -H -h -k -m)-h[human-readable output (base 2)]' - '(-b -g -H -h -k -m)-k[use 1024-byte blocks]' - '(-b -g -H -h -k -m)-m[use 1024*1024-byte blocks]' - '-P[POSIX compliant output]' - '-a[show all mount points]' - '-c[display a grand total]' - '-i[include inode usage statistics (default)]' + '(-b -g -H -h -k -m --si)-h[human-readable output (base 2)]' + '(-b -g -H -h -k -m --si)-k[use 1024-byte blocks]' + '(-G -i -P)-P[POSIX compliant output]' + '(-G -i -P)-i[include inode usage statistics (default)]' '-l[only display locally-mounted file systems]' '-n[use previously obtained statistics]' '*:files:_umountable' ) spec='[only display file systems of specified types]:file system type:->fslist' case "$OSTYPE" in + (darwin*|dragonfly*|freebsd*|netbsd*) + args+=( + '-a[show all mount points]' + '(-b -g -H -h -k -m --si)-g[use 1024^3-byte blocks]' + '(-b -g -H -h -k -m --si)-m[use 1024*1024-byte blocks]' + ) + ;| + (darwin*|dragonfly*|freebsd*) + args+=( + '(-b -g -H -h -k -m --si)-b[use 512-byte blocks (default)]' + '(-b -g -H -h -k -m --si)-H[human-readable output (base 10)]' + ) + ;| + (darwin*|freebsd*) + args+=( + '-c[display a grand total]' + ) + ;| (darwin*) args+=( "-T+$spec" "!-t+$spec" # obsolete ) ;; - (freebsd*|dragonfly*) - args+=( "-t+$spec" '-T[include file system type]' ) + (dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( + "-t+$spec" + ) + ;| + (dragonfly*|freebsd*) + args+=( + '-T[include file system type]' + ) + ;| + (freebsd*) + args+=( + '--libxo[generate output via libxo]' + '(-b -g -H -h -k -m --si)--si[human-readable output (base 10)]' + '-,[separate thousands]' + ) + ;; + (netbsd*) + args+=( + '(-G -i -P)-G[display all fields in statvfs]' + ) ;; esac else diff --git a/Completion/Unix/Command/_diff3 b/Completion/Unix/Command/_diff3 new file mode 100644 index 000000000..524507ce0 --- /dev/null +++ b/Completion/Unix/Command/_diff3 @@ -0,0 +1,46 @@ +#compdef diff3 + +local -a args ed +local ign + +if _pick_variant gnu=GNU unix; then + ed=( + '(-m --merge -A --show-all)'{-e,--ed}'[output ed script for incorporating changes]' + '(-m --merge -A --show-all)'{-E,--show-overlap}'[like -e, but bracket conflicts]' + '(-m --merge -A --show-all)'{-3,--easy-only}'[like -e, but incorporate only nonoverlapping changes]' + '(-m --merge -A --show-all)'{-x,--overlap-only}'[like -e, but incorporate only overlapping changes]' + '(-m --merge -A --show-all)-X[like -x, but bracket conflicts]' + ) + (( $#words > 2 )) && ign='!' + args=( + '(-A --show-all ed)'{-A,--show-all}'[output all changes, bracketing conflicts]' + "(-m --merge)-i[append 'w' and 'q' commands to ed scripts]" + '(-m --merge -i ed)'{-m,--merge}'[output merged file instead of ed script]' + '(-a --text)'{-a,--text}'[treat all files as text]' + '--strip-trailing-cr[strip trailing carriage return on input]' + '(-T --initial-tab)'{-T,--initial-tab}'[make tabs line up by prepending a tab]' + '--diff-program=[specify program to compare files]: : _command_names -e' + \*{-L+,--label=}'[use specified label instead of file name]:label' + "$ign(-)--help[display usage information]" + "$ign(-)"{-v,--version}'[display version information]' + ) +else + args=( -A "-*" ) + ed=( + '-e[output ed script for incorporating changes]' + '-E[like -e, but bracket conflicts]' + '-x[like -e, but incorporate only overlapping changes]' + '-X[like -x, but bracket conflicts]' + '-3[like -e, but incorporate only nonoverlapping changes]' + ) + if [[ $OSTYPE != solaris* ]]; then # likely the openbsd diff3 implementation + args+=( '-a[treat all files as text]' ) + fi +fi + +_arguments -s -S $args \ + '1: : _wanted files expl "first updated file (${${(As.:.)opt_args[-L]}[1]:-mine})" _files' \ + '2: : _wanted files expl "original file (${${(As.:.)opt_args[-L]}[2]:-old})" _files' \ + '3: : _wanted files expl "second updated file (${${(As.:.)opt_args[-L]}[3]:-their})" _files' \ + + '(ed)' $ed + diff --git a/Completion/Unix/Command/_dtruss b/Completion/Unix/Command/_dtruss new file mode 100644 index 000000000..bd1ae8bc5 --- /dev/null +++ b/Completion/Unix/Command/_dtruss @@ -0,0 +1,18 @@ +#compdef dtruss + +_arguments -s : \ + '-a[print all details]' \ + '-b+[specify dynamic variable buffer size]:buffer size (default 4m)' \ + '-c[print system call counts]' \ + '-d[print relative timestamps]' \ + '-e[print elapsed times]' \ + '-f[follow children as they are forked]' \ + '-l[force printing of pid/lwpid per line]' \ + "-L[don't print pid/lwpid per line]" \ + '(-p :)-n+[examine processes with the specified name]: : _process_names -a' \ + '-o[print on-cpu times]' \ + '-s[print stack backtraces]' \ + '(-n :)-p+[examine process with the specified pid]: : _pids' \ + '-t+[examine only the specified syscall]: : _sys_calls' \ + '1: : _command_names -e' \ + '*:: : _normal' diff --git a/Completion/Unix/Command/_du b/Completion/Unix/Command/_du index e812b635e..711f43471 100644 --- a/Completion/Unix/Command/_du +++ b/Completion/Unix/Command/_du @@ -6,7 +6,7 @@ if _pick_variant gnu=Free\ Soft unix --version /dummy/no-such-file; then _arguments -s \ '(-a --all -s --summarize)'{-a,--all}'[write counts for all files]' \ '--apparent-size[print apparent sizes rather than disc usage]' \ - '(-B --block-size -k)'{-B,--block-size=}'[specify block size]:size (bytes)' \ + '(-B --block-size -k)'{-B+,--block-size=}'[specify block size]:size (bytes)' \ '(-B --block-size -k --apparent-size -b --bytes)'{-b,--bytes}'[equivalent to --apparent-size --block-size=1]' \ '(-c --total)'{-c,--total}'[produce a grand total]' \ '(-H -D --dereference-args -L --dereference -P --no-dereference)'{-H,-D,--dereference-args}'[dereference arguments that are symlinks]' \ @@ -64,7 +64,7 @@ else 'netbsd*' '-i[output inode usage instead of blocks]' \ '(darwin*|freebsd*|netbsd*|solaris2.<11->)' '(-h -k -g -B)-m[use block size of 1M-byte]' \ '(darwin|freebsd<8->.|netbsd)*' '(-h -k -m -B)-g[use block size of 1G-byte]' \ - 'freebsd*' '(-h -k -m -g)-B[block size]:block size (bytes)' \ + 'freebsd*' '(-h -k -m -g)-B+[block size]:block size (bytes)' \ '(darwin|*bsd|dragonfly)*' '-c[display grand total]' \ 'freebsd*' '-l[count sizes many times if hard linked]' \ '(freebsd|netbsd)*' '-n[ignore files and directories with nodump flag set]' \ diff --git a/Completion/Unix/Command/_ed b/Completion/Unix/Command/_ed new file mode 100644 index 000000000..50d2710fc --- /dev/null +++ b/Completion/Unix/Command/_ed @@ -0,0 +1,38 @@ +#compdef ed + +local -a args + +args=( + '(-p --prompt)'{-p+,--prompt=}'[specify prompt]:prompt:' + '(-s --quiet --silent)'{-s,--quiet,--silent}'[suppress diagnostics]' +) + +if _pick_variant gnu=GNU unix --version; then + args+=( + '(-G --traditional)'{-G,--traditional}'[run in compatibility mode]' + '(- :)'{-h,--help}'[display help]' + '(-l --loose-exit-status)'{-l,--loose-exit-status}'[exit 0 even if a command fails]' + '(-r --restricted)'{-r,--restricted}'[run in restricted mode]' + '(- :)'{-V,--version}'[display version]' + '(-v --verbose)'{-v,--verbose}'[be verbose]' + ) +else + args=(-A '-*' ${args:#*\)--*}) + case $OSTYPE in + dragonfly*|freebsd*|netbsd*|solaris*) + args+=( + '-x[prompt for an encryption key]' + ) + ;| + netbsd*) + args+=( + '-E[enable extended regular expressions]' + '-S[disable ! command]' + ) + ;; + esac +fi + +_arguments -s -S \ + $args \ + ':file:_files' diff --git a/Completion/Unix/Command/_gcc b/Completion/Unix/Command/_gcc index a552bb2db..5b97b8c30 100644 --- a/Completion/Unix/Command/_gcc +++ b/Completion/Unix/Command/_gcc @@ -339,17 +339,32 @@ h8/300) esac if [[ "$service" = clang* ]]; then - args=( - $args - -flto -emit-llvm + args+=( + "-flto=-[generate output files suitable for link time optimization]::style:(full thin)" + -emit-llvm "-Qunused-arguments[don't emit warning for unused driver arguments]" --analyze -fshow-column -fshow-source-location -fcaret-diagnostics -fdiagnostics-fixit-info -fdiagnostics-parseable-fixits -fdiagnostics-print-source-range-info -fprint-source-range-info -fdiagnostics-show-option -fmessage-length + "-nostdinc[Do not search standard system directories or compiler builtin directories for include files]" + "-nostdlibinc[Do not search standard system directories for include files]" + "-nobuiltininc[Do not search builtin directory for include files]" + ) +else + args+=( + '-flto=-[Enable link-time optimization]::jobs:' ) fi +local -a sanitizers + sanitizers=( + address alignment bool bounds enum float-cast-overflow float-divide-by-zero + integer-divide-by-zero memory nonnull-attribute null nullability-arg nullability-assign + nullability-return object-size pointer-overflow return unsigned-integer-overflow + returns-nonnull-attribute shift signed-integer-overflow unreachable vla-bound vptr + ) + local -a languages languages=( c c-header cpp-output @@ -367,7 +382,6 @@ languages=( # generic options (from --help) args+=( - -a -C -H -P -s '-###[print commands to run this compilation]' '-o:output file:_files -g "^*.(c|h|cc|C|cxx)(-.)"' '-x[Specify the language of the following input files]:input file language:('"$languages"')' @@ -379,6 +393,10 @@ args+=( '*-A-:define assertion:' '*-D-:define macro:' '*-U-:undefine macro:' + '-C[do not discard comments during preprocess]' + '-CC[do not discard comments, including macro expansion]' + '-P[inhibit generation of linkemakers during preprocess]' + '-H[print name of each header file used]' '-E[Preprocess only; do not compile, assemble or link]' '-S[Compile only; do not assemble or link]' '-c[Compile and assemble, but do not link]' @@ -399,7 +417,7 @@ args+=( '-print-file-name=-[Display the full path to library <library>]:library:->library' '-print-prog-name=-[Display the full path to compiler component <program>]:program:' '*-specs=-[Override built-in specs with the contents of <file>]:file:_files' - '-std=-[assume that the input sources are for specified standard]:standard:(c90 c89 c99 c11 gnu90 gnu89 gnu99 gnu11 c++98 c++03 gnu++98 gnu++03 c++11 gnu++11 c++1y gnu++1y c++14 gnu++14 c++1z gnu++1z c++17 gnu++17 c++2a gnu++2a)' + '-std=-[assume that the input sources are for specified standard]:standard:(c90 c89 iso9899\:1990 iso9899\:199409 c99 iso9899\:1999 c11 iso9899\:2011 gnu90 gnu89 gnu99 gnu11 c++98 c++03 gnu++98 gnu++03 c++11 gnu++11 c++1y gnu++1y c++14 gnu++14 c++1z gnu++1z c++17 iso9899\:2017 gnu++17 c++2a gnu++2a)' '*-include:include file:_files -g \*.h\(-.\)' '*-imacros:macro input file:_files -g \*.h\(-.\)' '*-idirafter:second include path directory:_files -/' @@ -950,7 +968,7 @@ args+=( args+=( '-nostartfiles[Do not use the standard system startup files when linking]' '-nodefaultlibs[Do not use the standard system libraries when linking]' - '-nostdlib[Do not use the standard system startup files or libraries when linking]' + '-nostdlib[Do not use standard system startup files or libraries when linking]' '-rdynamic[Pass the flag -export-dynamic to the ELF linker, on targets that support it]' '-s[Remove all symbol table and relocation information from the executable]' '-static[On systems that support dynamic linking, this prevents linking with the shared libraries]' @@ -1034,7 +1052,6 @@ args+=( '-flto-odr-type-merging[Merge C++ types using One Definition Rule]' '-flto-partition=-[Partition symbols and vars at linktime based on object files they originate from]:partitioning algorithm:(1to1 balanced max one none)' '-flto-report[Report various link-time optimization statistics]' - '-flto=-[Enable link-time optimization]::jobs:' '-fmax-errors=-[Maximum number of errors to report]:errors: ' '-fmem-report-wpa[Report on permanent memory allocation in WPA only]' '-fmem-report[Report on permanent memory allocation]' @@ -1061,7 +1078,7 @@ args+=( '-freciprocal-math[Same as -fassociative-math for expressions which include division]' '-frecord-gcc-switches[Record gcc command line switches in the object file]' '-free[Turn on Redundant Extensions Elimination pass]' - '-fsanitize=-[Enable AddressSanitizer, a memory error detector]:style:(address thread)' + "-fsanitize=-[Enable AddressSanitizer, a memory error detector]:style:($sanitizers)" '-fsched-stalled-insns-dep=-[Set dependence distance checking in premature scheduling of queued insns]:instructions: ' '-fsched-stalled-insns=-[Set number of queued insns that can be prematurely scheduled]:instructions: ' '-fsched-verbose=-[Set the verbosity level of the scheduler]:verbosity: ' diff --git a/Completion/Unix/Command/_gdb b/Completion/Unix/Command/_gdb index 510e6f1fa..18f797633 100644 --- a/Completion/Unix/Command/_gdb +++ b/Completion/Unix/Command/_gdb @@ -5,12 +5,12 @@ local cur="$words[CURRENT]" prev w list ret=1 expl [[ "$PREFIX" = --* ]] && _arguments -- '*=(CORE|SYM)FILE:core file:_files' \ '*=EXECFILE:executable:_files -g \*\(-\*\)' \ - '*=TTY:terminal device:_ttys' && return 0 + '*=TTY: :_ttys -o' && return 0 if compset -P '-(cd|directory)='; then _files -/ elif compset -P '-tty='; then - _wanted devices expl 'terminal device' _ttys + _ttys -o elif compset -P '-(exec|se)='; then _description files expl executable _files "$expl[@]" -g '*(-*)' diff --git a/Completion/Unix/Command/_ghostscript b/Completion/Unix/Command/_ghostscript new file mode 100644 index 000000000..2c6f40a35 --- /dev/null +++ b/Completion/Unix/Command/_ghostscript @@ -0,0 +1,121 @@ +#compdef gs ghostscript + +local -a specs names device + +device=( ${${path[1,CURRENT-1]}[(R)-sDEVICE=*]} ) + +if compset -N '-[-+@]'; then + if [[ CURRENT -eq 1 ]]; then + _pspdf + else + _message -e arguments 'userdict ARGUMENTS' + return 1 + fi +elif compset -P '@'; then + _files +else + local curcontext="$curcontext" state line expl ret=1 + typeset -A opt_args + + _x_arguments -C \ + '-q[quiet startup]' \ + '-g-[set device size]:device size (<width>x<height>):' \ + '-r-[set resolution]:resolution (<val> or <x>x<y>):' \ + '-I+[add to library file search path]:directory:_dir_list' \ + \*-{d,D}'-[define name with definition]:def:->dname' \ + \*-{s,S}'-[define name with value]:def:->sname' \ + '-u[undefine name, cancelling -d or -s]:name:->uname' \ + '-P[look first in the current directory for library files]' \ + '-c[specify postscript code]:*[-@]*:postscript (-f to end)' \ + '-o+[specify OutputFile and enable -dPATCH and -dNOPAUSE options]: :->outfile' \ + '(- *)-'{h,\?}'[display useful options and available devices]' \ + '!-f-:PostScript or PDF file:_pspdf' \ + '*:PostScript or PDF file:_pspdf' && ret=0 + + [[ $state = sname ]] && compset -P '(stdout|OutputFile)=' && state=outfile + case "$state" in + dname) + if [[ "$PREFIX" = *\=* ]]; then + _message -e definition-values 'systemdict definition value' + else + names=( ${${(f)"$($words[1] -q -o /dev/null -DNODISPLAY -c 'systemdict { type /booleantype eq { = } if } forall')"}:#*[a-z]*} ) + _wanted boolean-definitions expl 'systemdict boolean definition' compadd -M 'm:{a-z}={A-Z}' -a names && ret=0 + names=( FirstPage LastPage + $($words[1] -q -o /dev/null $device -DNODISPLAY -c 'currentpagedevice { type /integertype eq { = } if } forall') ) + _wanted integer-definitions expl 'currentpagedevice integer definition' compadd -S = -M 'm:{a-z}={A-Z}' -a names && ret=0 + fi + ;; + sname) + if compset -P 1 '*='; then + case "$IPREFIX" in + *DEVICE\=) + _wanted devices expl 'ghostscript device' \ + compadd - ${(0)"$($words[1] -q -o /dev/null -DNODISPLAY -c 'devicenames { dup length string cvs print (\0) print } forall')"} && ret=0 + ;; + *PAPERSIZE=) + names=( $($words[1] -q -o /dev/null -DNODISPLAY -c 'statusdict /.pagetypenames get { = } forall ') ) + _description paper-sizes expl 'paper size' + compadd "$expl[@]" -a names && ret=0 + ;; + *PDFSETTINGS=) + _description settings expl 'configuration' + compadd "$expl[@]" /screen /ebook /printer /prepress /default && ret=0 + ;; + *AutoRotatePages=) + _description settings expl 'orientation selection' + compadd "$expl[@]" /None /All /PageByPage && ret=0 + ;; + *CompatibilityLevel=) + _description pdf-levels expl 'PDF compatibility level' + compadd "$expl[@]" 1.{2,3,4} && ret=0 + ;; + *FONT=) # e.g. SUBSTFONT + _wanted fonts expl 'font' compadd - \ + $($words[1] -q -o /dev/null -DNODISPLAY -c '(*) { = } 256 string /Font resourceforall') && ret=0 + ;; + *) + _message -e values 'systemdict value' + return 1 + ;; + esac + else + _wanted definition-names expl 'systemdict name' compadd -S\= -M 'm:{a-z}={A-Z}' - \ + DEVICE OutputFile PAPERSIZE PDFSETTINGS CompatibilityLevel stdout COLORSCREEN \ + DITHERPPI InterpolateControl TextAlphaBits GraphicsAlphaBits PageList SUBSTFONT \ + && ret=0 + fi + ;; + uname) + _message -e definition-names 'systemdict definition name' + ;; + outfile) + if compset -P "*%"; then + specs=( + {d,i}':signed decimal number or with leading " numeric value of following character' + 'o:unsigned octal number' + 'u:unsigned decimal number' + {x,X}':unsigned hexadecimal number, letters capitalized as x' + '%:a literal percent sign' + '#:alternate form' + '0:zero pad to length' + '-:left adjust result' + '+:always place sign before number' + '.:precision' + ) + if ! compset -P '[0-9#.+-]##'; then + specs+=( + 'stdout:redirect to standard output' + 'stderr:redirect to standard error' + 'pipe%:redirect to a pipe' + ) + fi + _describe -t print-format-specifiers 'print format specifier' specs -S '' && ret=0 + else + _description files expl 'output file' + _files "$expl[@]" && ret=0 + fi + ;; + esac + + return ret +fi diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index f6cec8b60..eac0c8476 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -871,6 +871,7 @@ _git-fetch () { '(-n --no-tags -t --tags)'{-n,--no-tags}'[disable automatic tag following]' \ '(--all -m --multiple)'{-m,--multiple}'[fetch from multiple remotes]' \ '(-P --prune-tags)'{-P,--prune-tags}'[prune local tags no longer on remote and clobber changed tags]' \ + \*{-o+,--server-option=}'[send specified string to the server when using protocol version 2]:option' \ '--filter=[object filtering]:filter:_git_rev-list_filters' \ '*:: :->repository-or-group-or-refspec' && ret=0 @@ -959,9 +960,10 @@ _git-gc () { _arguments -S -s \ '--aggressive[more aggressively optimize]' \ '--auto[check whether housekeeping is required]' \ - '( --no-prune)--prune=[prune loose objects older than given date]: :__git_datetimes' \ + '( --no-prune)--prune=-[prune loose objects older than given date]::date [2 weeks ago]:__git_datetimes' \ '(--prune )--no-prune[do not prune any loose objects]' \ - '(-q --quiet)'{-q,--quiet}'[suppress progress reporting]' + '(-q --quiet)'{-q,--quiet}'[suppress progress reporting]' \ + '--keep-largest-pack[repack all other packs except the largest pack]' \ } (( $+functions[_git-grep] )) || @@ -1694,6 +1696,9 @@ _git-stash () { '(-m --message)'{-m,--message}'[specify stash description]' \ ':: :__git_modified_files' && ret=0 ;; + (--) + __git_modified_files + ;; (list) local -a log_options revision_options __git_setup_log_options @@ -1765,7 +1770,10 @@ _git-status () { '--ignored=-[show ignored files as well]:mode [traditional]:(traditional matching no)' \ '(-z --null --column --no-column)'{-z,--null}'[use NUL termination on output]' \ '(--no-column -z --null)--column=-[display in columns]::column.status option:((always\:"always show in columns" never\:"never show in columns" auto\:"show in columns if the output is to the terminal" column\:"fill columns before rows (default)" row\:"fill rows before columns" plain\:"show in one column" dense\:"make unequal size columns to utilize more space" nodense\:"make equal size columns"))' \ - '(--column)--no-column[do not display in columns]' \ + "(--column)--no-column[don't display in columns]" \ + "(--no-renames -M --find-renames)--no-renames[don't detect renames]" \ + '(--no-renames -M --find-renames)-M[detect renames]' \ + '(--no-renames -M --find-renames)--find-renames=-[detect renames, optionally set similarity index]::similarity' \ '*: :__git_ignore_line_inside_arguments _files' } @@ -2152,16 +2160,18 @@ _git-config () { '(--global --system -f --file --blob)--local[use local config file]' \ '(--global --system --local --blob)'{-f+,--file=}'[use given config file]:config file:_files' \ '(--global --system --local -f --file)--blob=[read config from given blob object]:blob:__git_blobs' \ - '( --int --bool-or-int --path --expiry-date)--bool[setting is a boolean]' \ - '(--bool --bool-or-int --path --expiry-date)--int[setting is an integer]' \ - '(--bool --int --path --expiry-date)--bool-or-int[setting is an integer]' \ - '(--bool --int --bool-or-int --expiry-date)--path[setting is a path]' \ - '(--bool --int --bool-or-int --path )--expiry-date[setting is an expiry date]' \ + '(-t --type --bool --int --bool-or-int --path --expiry-date)'{-t+,--type=}'[ensure that incoming and outgoing values are canonicalize-able as the given type]:type:(bool int bool-or-int path expiry-date color)' \ + '(-t --type --int --bool-or-int --path --expiry-date)--bool[setting is a boolean]' \ + '(-t --type --bool --bool-or-int --path --expiry-date)--int[setting is an integer]' \ + '(-t --type --bool --int --path --expiry-date)--bool-or-int[setting is an integer]' \ + '(-t --type --bool --int --bool-or-int --expiry-date)--path[setting is a path]' \ + '(-t --type --bool --int --bool-or-int --path)--expiry-date[setting is an expiry date]' \ '(-z --null)'{-z,--null}'[end values with NUL and newline between key and value]' \ '(--get --get-all --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section -e --edit --get-color --get-colorbool)--name-only[show variable names only]' \ '(--includes)'--no-includes"[don't respect \"include.*\" directives]" \ '(--no-includes)'--includes'[respect "include.*" directives in config files when looking up values]' \ '(--global --system --local -f --file --blob --get-urlmatch --replace-all --add --unset --unset-all --rename-section --remove-section -e --edit --get-color --get-colorbool)--show-origin[show origin of config]' \ + '(2 --add -e --edit -l --list --name-only --rename-section --remove-section --replace-all --unset --unset-all)--default=[with --get, use specified default value when entry is missing]:default' \ $name_arg \ $value_arg \ '::value regex' \ @@ -3705,11 +3715,17 @@ _git-replace () { '(: * --raw -f --force)'{-l,--list}'[list replace refs]:pattern' \ {-d,--delete}'[delete existing replace refs]:*:replacement:__git_objects' \ '(* 2 --format)'{-e,--edit}'[edit existing object and replace it with the new one]' \ - '(--raw --format)'{-g,--graft}'[rewrite the parents of a commit]' + '(--raw --format)'{-g,--graft}'[rewrite the parents of a commit]' \ + '--convert-graft-file[convert existing graft file]' } # Ancillary Commands (Interrogators) +(( $+functions[_git-annotate] )) || +_git-annotate() { + _git-blame "$@" +} + (( $+functions[_git-blame] )) || _git-blame () { local curcontext=$curcontext state line ret=1 @@ -3741,6 +3757,8 @@ _git-blame () { '(-n --show-number)'{-n,--show-number}'[show the line number in the original commit]' \ '-s[suppress author name and timestamp]' \ '-w[ignore whitespace when finding lines]' \ + '(--color-by-age)--color-lines[color redundant metadata from previous line differently]' \ + '(--color-lines)--color-by-age[color lines by age]' \ '--indent-heuristic[use indent-based heuristic to improve diffs]' \ $revision_options \ ':: :__git_revisions' \ @@ -3828,10 +3846,11 @@ _git-get-tar-commit-id () { _git-help () { _arguments -S -s \ '( -g --guides -i --info -m --man -w --web)'{-a,--all}'[show all available commands]' \ - '(-a --all -g --guides -m --man -w --web)'{-i,--info}'[show all available commands]' \ - '(-a --all -g --guides -i --info -w --web)'{-m,--man}'[show all available commands]' \ - '(-a --all -g --guides -i --info -m --man )'{-w,--web}'[show all available commands]' \ + '(-a --all -g --guides -m --man -w --web)'{-i,--info}'[display manual for the command in info format]' \ + '(-a --all -g --guides -i --info -w --web)'{-m,--man}'[display manual for the command in man format]' \ + '(-a --all -g --guides -i --info -m --man )'{-w,--web}'[display manual for the command in HTML format]' \ '(-g --guides)'{-g,--guides}'[prints a list of useful guides on the standard output]' \ + '(-v --verbose)'{-v,--verbose}'[print command descriptions]' \ ': : _alternative commands:command:_git_commands "guides:git guides:(attributes glossary ignore modules revisions tutorial workflows)"' } @@ -4700,6 +4719,7 @@ _git-pack-objects () { $thin_opt \ '--shallow[create packs suitable for shallow fetches]' \ '--honor-pack-keep[ignore objects in local pack with .keep file]' \ + '--keep-pack=[ignore named pack]:pack' \ '--compression=-[specify compression level]: :__git_compression_levels' \ '--keep-true-parents[pack parents hidden by grafts]' \ '--use-bitmap-index[use a bitmap index if available to speed up counting objects]' \ @@ -5034,7 +5054,9 @@ _git-ls-remote () { "--refs[don't show peeled tags]" \ '--exit-code[exit with status 2 when no matching refs are found in the remote repository]' \ '--get-url[expand the URL of the given repository taking into account any "url.<base>.insteadOf" config setting]' \ + '*--sort=[specify field name to sort on]:field:__git_ref_sort_keys' \ '--symref[show underlying ref in addition to the object pointed by it]' \ + \*{-o+,--server-option=}'[send specified string to the server when using protocol version 2]:option' \ ': :__git_any_repositories' \ '*: :__git_references' } @@ -5615,7 +5637,7 @@ __git_describe_branch () { (( $+functions[__git_describe_commit] )) || __git_describe_commit () { - __git_describe_branch $1 $2 $3 -M 'r:|/=**' "${(@)argv[4,-1]}" + __git_describe_branch $1 $2 $3 -M 'r:|/=* r:|=*' "${(@)argv[4,-1]}" } # Completion Wrappers @@ -6404,7 +6426,7 @@ __git_heads () { (( $+functions[__git_heads_local] )) || __git_heads_local () { - local gitdir + local f gitdir declare -a heads heads=(${(f)"$(_call_program headrefs git for-each-ref --format='"%(refname:short)"' refs/heads 2>/dev/null)"}) @@ -6532,7 +6554,7 @@ __git_recent_commits () { expl=() _wanted commit-tags expl 'commit tag' compadd "$@" -a - tags && ret=0 expl=() - _wanted heads expl 'head' compadd "$@" -a - heads && ret=0 + _wanted heads expl 'head' compadd -M "r:|/=* r:|=*" "$@" -a - heads && ret=0 return $ret } @@ -6657,7 +6679,7 @@ __git_tags () { tags=(${${(f)"$(_call_program tagrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) __git_command_successful $pipestatus || return 1 - _wanted tags expl tag compadd -M 'r:|/=**' "$@" -a - tags + _wanted tags expl tag compadd -M 'r:|/=* r:|=*' "$@" -a - tags } (( $+functions[__git_commit_tags] )) || @@ -6680,7 +6702,7 @@ __git_tags_of_type () { tags=(${${(M)${(f)"$(_call_program ${(q)type}-tag-refs "git for-each-ref --format='%(*objecttype)%(objecttype) %(refname)' refs/tags 2>/dev/null")"}:#$type(tag|) *}#$type(tag|) refs/tags/}) __git_command_successful $pipestatus || return 1 - _wanted $type-tags expl "$type tag" compadd -M 'r:|/=**' "$@" -a - tags + _wanted $type-tags expl "$type tag" compadd -M 'r:|/=* r:|=*' "$@" -a - tags } # Reference Argument Types @@ -6703,7 +6725,7 @@ __git_references () { _git_refs_cache_pwd=$PWD fi - _wanted references expl 'reference' compadd -M 'r:|/=**' -a - _git_refs_cache + _wanted references expl 'reference' compadd -M 'r:|/=* r:|=*' -a - _git_refs_cache } # ### currently unused; are some callers of __git_references supposed to call this function? @@ -6717,7 +6739,7 @@ __git_local_references () { _git_local_refs_cache_pwd=$PWD fi - _wanted references expl 'reference' compadd -M 'r:|/=**' -a - _git_local_refs_cache + _wanted references expl 'reference' compadd -M 'r:|/=* r:|=*' -a - _git_local_refs_cache } (( $+functions[__git_remote_references] )) || @@ -6790,7 +6812,7 @@ __git_files () { local pref=$gitcdup$gitprefix$PREFIX # First allow ls-files to pattern-match in case of remote repository - files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\\\*}:-.} 2>/dev/null)"}) + files=(${(0)"$(_call_program files git ls-files -z --exclude-standard ${(q)opts} -- ${(q)${pref:+$pref\*}:-.} 2>/dev/null)"}) __git_command_successful $pipestatus || return # If ls-files succeeded but returned nothing, try again with no pattern @@ -7739,8 +7761,8 @@ _git() { '(: -)--man-path[print the manpath for the man pages for this version of Git and exit]' \ '(: -)--info-path[print the path where the info files are installed and exit]' \ '(: -)--html-path[display path to HTML documentation and exit]' \ - '(-p --paginate)'{-p,--paginate}'[pipe output into $PAGER]' \ - '--no-pager[do not pipe git output into a pager]' \ + '(-p --paginate -P --no-pager)'{-p,--paginate}'[pipe output into a pager]' \ + '(-p --paginate -P --no-pager)'{-P,--no-pager}"[don't pipe git output into a pager]" \ '--git-dir=-[path to repository]: :_directories' \ '--work-tree=-[path to working tree]: :_directories' \ '--namespace=-[set the Git namespace]: :_directories' \ @@ -7758,7 +7780,10 @@ _git() { curcontext=${curcontext%:*:*}:git-$words[1]: (( $+opt_args[--git-dir] )) && local -x GIT_DIR=$opt_args[--git-dir] if ! _call_function ret _git-$words[1]; then - if zstyle -T :completion:$curcontext: use-fallback; then + if [[ $words[1] = \!* ]]; then + words[1]=${words[1]##\!} + _normal && ret=0 + elif zstyle -T :completion:$curcontext: use-fallback; then _default && ret=0 else _message "unknown sub-command: $words[1]" diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg index 48a36eff2..b35693d1f 100644 --- a/Completion/Unix/Command/_gpg +++ b/Completion/Unix/Command/_gpg @@ -206,20 +206,68 @@ fi case "$state" in public-keys) - _wanted public-keys expl 'public key' \ - compadd ${${(Mo)$(_call_program public-keys $words[1] $needed --list-public-keys --list-options no-show-photos):%<*>}//(<|>)/} && return + local public_keys_lines=(${(f)"$(_call_program public-keys ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"}) + local -a uids emails + local i j parts current_uid + for (( i = 1; i < ${#public_keys_lines[@]}; ++i )); do + parts=("${(@s.:.)public_keys_lines[$i]}") + if [[ ${parts[1]} == "fpr" ]]; then + current_uid="${parts[10]}" + i=$((i + 1)) + parts=("${(@s.:.)public_keys_lines[$i]}") + while [[ ${parts[1]} == "uid" ]]; do + uids+=("${current_uid}") + emails+=("${parts[10]}") + i=$((i + 1)) + parts=("${(@s.:.)public_keys_lines[$i]}") + done + fi + done + _describe -t public-keys 'public key' emails uids ;; secret-keys) - _wanted secret-keys expl 'secret key' compadd \ - ${${(Mo)$(_call_program secret-keys $words[1] $needed --list-secret-keys --list-options no-show-photos):%<*>}//(<|>)/} && return + local secret_keys_lines=(${(f)"$(_call_program secret-keys ${(q)words[1]} ${(q)needed} --list-secret-keys --list-options no-show-photos --with-colons)"}) + local -a uids emails + local i j parts current_uid + for (( i = 1; i < ${#secret_keys_lines[@]}; ++i )); do + parts=("${(@s.:.)secret_keys_lines[$i]}") + if [[ ${parts[1]} == "fpr" ]]; then + current_uid="${parts[10]}" + i=$((i + 1)) + parts=("${(@s.:.)secret_keys_lines[$i]}") + while [[ ${parts[1]} == "uid" ]]; do + uids+=("${current_uid}") + emails+=("${parts[10]}") + i=$((i + 1)) + parts=("${(@s.:.)secret_keys_lines[$i]}") + done + fi + done + _describe -t secret-keys 'secret key' emails uids ;; ciphers) _wanted ciphers expl cipher compadd \ - ${${(s.,.)${(M)${(f)${"$(_call_program ciphers $words[1] $needed --version)"}//,$'\n' #/, }:#Cipher*}#*:}# } && return + ${${(s.,.)${(M)${(f)${"$(_call_program ciphers ${(q)words[1]} ${(q)needed} --version)"}//,$'\n' #/, }:#Cipher*}#*:}# } && return ;; (public-keyids) - _wanted public-keys expl 'public keyid' \ - compadd ${(M)${${(f)"$(_call_program public-keyids $words[1] $needed --list-public-keys --list-options no-show-photos)"}## #}:#[0-9A-F](#c40)} && return + local public_keys_lines=(${(f)"$(_call_program public-keyids ${(q)words[1]} ${(q)needed} --list-public-keys --list-options no-show-photos --with-colons)"}) + local -a uids emails + local i j parts current_uid + for (( i = 1; i < ${#public_keys_lines[@]}; ++i )); do + parts=("${(@s.:.)public_keys_lines[$i]}") + if [[ ${parts[1]} == "fpr" ]]; then + current_uid="${parts[10]}" + i=$((i + 1)) + parts=("${(@s.:.)public_keys_lines[$i]}") + while [[ ${parts[1]} == "uid" ]]; do + uids+=("${current_uid}") + emails+=("${parts[10]}") + i=$((i + 1)) + parts=("${(@s.:.)public_keys_lines[$i]}") + done + fi + done + _describe -t public-keyids 'public key' emails uids ;; (option-list) _sequence _wanted options expl option \ diff --git a/Completion/Unix/Command/_grep b/Completion/Unix/Command/_grep index 5f45ce9a8..3bc8d3fe0 100644 --- a/Completion/Unix/Command/_grep +++ b/Completion/Unix/Command/_grep @@ -1,4 +1,4 @@ -#compdef grep egrep fgrep bsdgrep zgrep zegrep zfgrep ggrep gegrep gfgrep gzgrep gzegrep gzfgrep -value-,GREP_OPTIONS,-default- +#compdef grep egrep fgrep bsdgrep zgrep zegrep zfgrep ggrep gegrep gfgrep gzgrep gzegrep gzfgrep bzgrep bzegrep bzfgrep -value-,GREP_OPTIONS,-default- local arguments matchers command variant @@ -11,13 +11,15 @@ else arguments=( '(-e --regexp -f --file)1: :_guard "^-*" pattern' ) if [[ $service = z* ]]; then arguments+=( '*:files:_files -g "*.gz(-.)"' ) + elif [[ $service = bz* ]]; then + arguments+=( '*:files:_files -g "*.bz2(-.)"' ) else arguments+=( '*:files:_files' ) fi command="$words[1]" fi -if [[ $service != (|g)(|z)[ef]grep ]]; then +if [[ $service != (|g|z|gz|bz)[ef]grep ]]; then matchers='(--extended-regexp --fixed-strings --basic-regexp --perl-regexp -E -F -G -P)' arguments+=( $matchers{--extended-regexp,-E}'[use extended regular expression]' @@ -66,7 +68,7 @@ arguments+=( _pick_variant -r variant -c "$command" gnu=gnu gpl2=2.5.1 unix --version case $variant:$OSTYPE in (gnu:*|gpl2:freebsd*)) - [[ $service != (|g)(|z)[ef]grep ]] && arguments+=( + [[ $service != (|g|z|gz|bz)[ef]grep ]] && arguments+=( $matchers{--perl-regexp,-P}'[use perl regular expression]' ) ;| @@ -76,15 +78,19 @@ case $variant:$OSTYPE in '(-z --null-data)'{-z,--null-data}'[input data separated by 0 byte, not newline]' ) ;| - gpl2:freebsd*) + gpl2:(freebsd|darwin)*) arguments+=( '(--null --no-filename -h)--null[print 0 byte after each filename]' + '(-Z --decompress -J --bz2decompress)'{-J,--bz2decompress}"[decompress bzip2'ed input before searching]" + '(-Z --decompress -J --bz2decompress)'{-Z,--decompress}"[decompress gzip'ed input before searching]" ) ;| - gpl2:(freebsd|darwin)*) + gpl2:darwin*) arguments+=( - '(-Z --decompress -J --bz2decompress)'{-J,--bz2decompress}"[decompress bzip2'ed input before searching]" - '(-Z --decompress -J --bz2decompress)'{-Z,--decompress}"[decompress gzip'ed input before searching]" + '(-p -S)-O[follow symlinks on the command line]' + '(-O -S)-p[do not follow symlinks]' + '(-O -p)-S[follow all symlinks]' + '*--include-dir=[only search directories matching specified pattern]:directory pattern' ) ;| (gnu:*|gpl2:netbsd*)) diff --git a/Completion/Unix/Command/_gs b/Completion/Unix/Command/_gs deleted file mode 100644 index 98ba14912..000000000 --- a/Completion/Unix/Command/_gs +++ /dev/null @@ -1,57 +0,0 @@ -#compdef gs ghostscript - -if compset -N --; then - if [[ CURRENT -eq 1 ]]; then - _pspdf - else - _message -e arguments 'userdict ARGUMENTS' - return 1 - fi -else - local curcontext="$curcontext" state line expl ret=1 - typeset -A opt_args - - _x_arguments -C \ - '-q[quiet startup]' \ - '-g-[set device size]:device size (<width>x<height>):' \ - '-r-[set resolution]:resolution (<val> or <x>x<y>):' \ - '-I[add to library file search path]:directory:_dir_list' \ - \*-{d,D}'-[define name with definition]:def:->dname' \ - \*-{s,S}'-[define name with value]:def:->sname' \ - '*:PostScript or PDF file:_pspdf' && ret=0 - - case "$state" in - dname) - if [[ "$PREFIX" = *\=* ]]; then - _message -e definition-values 'systemdict definition value' - else - _wanted names expl 'systemdict definition name' \ - compadd -M 'm:{a-z}={A-Z}' - \ - DISKFONTS NOCACHE NOBIND NODISPLAY NOPAUSE PLATFONTS SAFER \ - WRITESYSTEMDICT && ret=0 - fi - ;; - sname) - if compset -P 1 '*='; then - case "$IPREFIX" in - *DEVICE\=) - _wanted devices expl 'ghostscript device' \ - compadd - "${(@)${=${$(_call_program devices gs -h)##* devices:}%%Search path:*}:#}" && ret=0 - ;; - *OutputFile\=) - _description files expl 'output file' - _files "$expl[@]" && ret=0 - ;; - *) - _message -e values 'systemdict value' - return 1 - esac - else - _wanted names expl 'systemdict name' \ - compadd -S\= -M 'm:{a-z}={A-Z}' - DEVICE OutputFile && ret=0 - fi - ;; - esac - - return ret -fi diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg index 8eaa457c8..4b88ce4ea 100644 --- a/Completion/Unix/Command/_hg +++ b/Completion/Unix/Command/_hg @@ -82,7 +82,7 @@ _hg() { if [[ -z "$cmd" ]] then - _arguments -s -w : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ ':mercurial command:_hg_commands' return fi @@ -119,7 +119,7 @@ _hg() { _hg_cmd_${cmd} else # complete unknown commands normally - _arguments -s -w : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '*:files:_hg_files' fi } @@ -282,6 +282,18 @@ _hg_config() { (( $#items )) && _describe -t config 'config item' items } +_hg_internal_merge_tools=( + \\:dump \\:fail \\:local \\:merge \\:merge-local \\:merge-other \\:merge3 + \\:other \\:prompt \\:tagmerge \\:union +) + +_hg_merge_tools() { + typeset -a external_tools + _describe -t internal_tools 'internal merge tools' _hg_internal_merge_tools + external_tools=(${(f)"$(_hg_cmd showconfig merge-tools | cut -d . -f 2)"}) + (( $#external_tools )) && _describe -t external_tools 'external merge tools' external_tools +} + _hg_addremove() { _alternative 'files:unknown files:_hg_unknown' \ 'files:missing files:_hg_missing' @@ -359,22 +371,22 @@ _hg_clone_dest() { # Common options _hg_global_opts=( - '(--repository -R)'{-R+,--repository=}'[repository root directory]:repository:_files -/' - '--cwd[change working directory]:new working directory:_files -/' - '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, assume yes for any required answers]' + '(--repository -R)'{-R+,--repository=}'[repository root directory or name of overlay bundle file]:repository:_files -/' + '--cwd=[change working directory]:new working directory:_files -/' + '(--noninteractive -y)'{-y,--noninteractive}'[do not prompt, automatically pick the first choice for all prompts]' '(--verbose -v)'{-v,--verbose}'[enable additional output]' '*--config[set/override config option]:defined config items:_hg_config' '(--quiet -q)'{-q,--quiet}'[suppress output]' '(--help -h)'{-h,--help}'[display help and exit]' - '--debug[debug mode]' + '--debug[enable debugging output]' '--debugger[start debugger]' - '--encoding[set the charset encoding (default: UTF8)]' - '--encodingmode[set the charset encoding mode (default: strict)]' - '--lsprof[print improved command execution profile]' - '--traceback[print traceback on exception]' + '--encoding=[set the charset encoding]:encoding' + '--encodingmode=[set the charset encoding mode]:encoding mode' + '--traceback[always print a traceback on exception]' '--time[time how long the command takes]' - '--profile[profile]' + '--profile[print command execution profile]' '--version[output version information and exit]' + '--hidden[consider hidden changesets]' ) _hg_pat_opts=( @@ -384,14 +396,19 @@ _hg_pat_opts=( _hg_diff_opts=( '(--text -a)'{-a,--text}'[treat all files as text]' '(--git -g)'{-g,--git}'[use git extended diff format]' - "--nodates[don't include dates in diff headers]") + '--nodates[omit dates from diff headers]' +) + +_hg_mergetool_opts=( + '(--tool -t)'{-t+,--tool=}'[specify merge tool]:merge tool:_hg_merge_tools' +) _hg_dryrun_opts=( '(--dry-run -n)'{-n,--dry-run}'[do not perform actions, just print output]') -_hg_style_opts=( - '--style[display using template map file]:' - '--template[display with template]:') +_hg_template_opts=( + '--template[display with template]:template' +) _hg_commit_opts=( '(-m --message -l --logfile --edit -e)'{-e,--edit}'[edit commit message]' @@ -399,8 +416,14 @@ _hg_commit_opts=( '(-e --edit -m --message --logfile -l)'{-l+,--logfile=}'[read the commit message from <file>]:log file:_files') _hg_remote_opts=( - '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:' - '--remotecmd[specify hg command to run on the remote side]:') + '(--ssh -e)'{-e+,--ssh=}'[specify ssh command to use]:command' + '--remotecmd=[specify hg command to run on the remote side]:remote command' + '--insecure[do not verify server certificate (ignoring web.cacerts config)]' +) + +_hg_subrepos_opts=( + '(--subrepos -S)'{-S,--subrepos}'[recurse into subrepositories]' +) _hg_cmd() { _call_program hg hg --config ui.verbose=0 --config defaults."$1"= \ @@ -408,51 +431,54 @@ _hg_cmd() { } _hg_cmd_add() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \ '*:unknown files:_hg_unknown' } _hg_cmd_addremove() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ - '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:' \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts $_hg_subrepos_opts \ + '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \ '*:unknown or missing files:_hg_addremove' } _hg_cmd_annotate() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ '(--rev -r)'{-r+,--rev=}'[annotate the specified revision]:revision:_hg_tags' \ - '(--follow -f)'{-f,--follow}'[follow file copies and renames]' \ + "--no-follow[don't follow copies and renames]" \ '(--text -a)'{-a,--text}'[treat all files as text]' \ - '(--user -u)'{-u,--user}'[list the author]' \ - '(--date -d)'{-d,--date}'[list the date]' \ + '(--user -u)'{-u,--user}'[list the author (long with -v)]' \ + '(--file -f)'{-f,--file}'[list the filename]' \ + '(--date -d)'{-d,--date}'[list the date (short with -q)]' \ '(--number -n)'{-n,--number}'[list the revision number (default)]' \ '(--changeset -c)'{-c,--changeset}'[list the changeset]' \ + '(--line-number -l)'{-l,--line-number}'[show line number at the first appearance]' \ '*:files:_hg_files' } _hg_cmd_archive() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ '--no-decode[do not pass files through decoders]' \ - '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:' \ + '(--prefix -p)'{-p+,--prefix=}'[directory prefix for files in archive]:prefix' \ '(--rev -r)'{-r+,--rev=}'[revision to distribute]:revision:_hg_tags' \ '(--type -t)'{-t+,--type=}'[type of distribution to create]:archive type:(files tar tbz2 tgz uzip zip)' \ '*:destination:_files' } _hg_cmd_backout() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts $_hg_pat_opts \ '--merge[merge with old dirstate parent after backout]' \ - '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \ + '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ '--parent[parent to choose when backing out merge]' \ - '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \ + '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \ '(--message -m)'{-m+,--message=}'[specify commit message]:text' \ '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files' } _hg_cmd_bisect() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(-)'{-r,--reset}'[reset bisect state]' \ + '(--extend -e)'{-e,--extend}'[extend the bisect range]' \ '(--good -g --bad -b --skip -s --reset -r)'{-g,--good}'[mark changeset good]'::revision:_hg_tags \ '(--good -g --bad -b --skip -s --reset -r)'{-b,--bad}'[mark changeset bad]'::revision:_hg_tags \ '(--good -g --bad -b --skip -s --reset -r)'{-s,--skip}'[skip testing changeset]' \ @@ -461,97 +487,115 @@ _hg_cmd_bisect() { } _hg_cmd_bookmarks() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--force -f)'{-f,--force}'[force]' \ - '(--rev -r)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \ - '(--delete -d)'{-d,--delete}'[delete a given bookmark]' \ - '(--rename -m)'{-m+,--rename=}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \ + '(--rev -r --delete -d --rename -m)'{-r+,--rev=}'[set bookmark at revision]:revision:_hg_tags' \ + '(--rev -r --delete -d --rename -m)'{-d,--delete}'[delete a given bookmark]' \ + '(--rev -r --delete -d --rename -m)'{-m+,--rename=}'[rename given bookmark]:bookmark:_hg_bookmarks_internal' \ '(--inactive -i)'{-i,--inactive}'[mark a bookmark inactive]' \ ':bookmark:_hg_bookmarks_internal' } _hg_cmd_branch() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--force -f)'{-f,--force}'[set branch name even if it shadows an existing branch]' \ '(--clean -C)'{-C,--clean}'[reset branch name to parent branch name]' } _hg_cmd_branches() { - _arguments -s : $_hg_global_opts \ - '(--active -a)'{-a,--active}'[show only branches that have unmerge heads]' + _arguments -s -S : $_hg_global_opts \ + '(--closed -c)'{-c,--closed}'[show normal and closed branches]' } _hg_cmd_bundle() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ - '(--force -f)'{-f,--force}'[run even when remote repository is unrelated]' \ - '(2)*--base[a base changeset to specify instead of a destination]:revision:_hg_tags' \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ + '(--force -f)'{-f,--force}'[run even when the destination is unrelated]' \ + '(2)*--base[a base changeset assumed to be available at the destination]:revision:_hg_tags' \ + '*'{-b+,--branch=}'[a specific branch you would like to bundle]:branch:_hg_branches_internal' \ + '*'{-r+,--rev=}'[a changeset intended to be added to the destination]:revision:_hg_tags' \ + '--all[bundle all changesets in the repository]' \ + '--type[bundle compression type to use (default: bzip2)]:bundle type' \ ':output file:_files' \ ':destination repository:_files -/' } _hg_cmd_cat() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ - '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:filespec:' \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ + '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \ '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \ + '--decode[apply any matching decode filter]' \ '*:file:_hg_files' } _hg_cmd_clone() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ '(--noupdate -U)'{-U,--noupdate}'[do not update the new working directory]' \ - '(--rev -r)'{-r+,--rev=}'[a changeset you would like to have after cloning]:' \ + '(--rev -r)'{-r+,--rev=}'[include the specified changeset]:revision' \ '--uncompressed[use uncompressed transfer (fast over LAN)]' \ ':source repository:_hg_remote' \ ':destination:_hg_clone_dest' } _hg_cmd_commit() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ '(--addremove -A)'{-A,--addremove}'[mark new/missing files as added/removed before committing]' \ '(--message -m)'{-m+,--message=}'[specify commit message]:text' \ '(--logfile -l)'{-l+,--logfile=}'[read commit message from specified file]:log file:_files' \ - '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \ - '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \ + '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ + '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ + '--amend[amend the parent of the working directory]' \ + '--close-branch[mark a branch head as closed]' \ + '(--interactive -i)'{-i,--interactive}'[use interactive mode]' \ + '(--secret -s)'{-s,--secret}'[use the secret phase for committing]' \ '*:file:_hg_committable' } _hg_cmd_copy() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ '(--after -A)'{-A,--after}'[record a copy that has already occurred]' \ '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ '*:file:_hg_files' } _hg_cmd_diff() { + local context state state_descr line ret=1 typeset -A opt_args - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \ + + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts $_hg_subrepos_opts \ '*'{-r+,--rev=}'[revision]:revision:_hg_revrange' \ '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \ '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \ '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \ '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \ - '*:file:->diff_files' + '*:file:->diff_files' && ret=0 if [[ $state == 'diff_files' ]] then if [[ -n $opt_args[-r] ]] then - _hg_files + _hg_files && ret=0 else - _hg_modified + _hg_modified && ret=0 fi fi + + return ret } _hg_cmd_export() { - _arguments -s : $_hg_global_opts $_hg_diff_opts \ - '(--outout -o)'{-o+,--output}'[print output to file with formatted name]:filespec:' \ + _arguments -s -S : $_hg_global_opts $_hg_diff_opts \ + '(--output -o)'{-o+,--output=}'[print output to file with formatted name]:format string' \ '--switch-parent[diff against the second parent]' \ '*:revision:_hg_tags' } +_hg_cmd_forget() { + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ + '*:file:_hg_files' +} + _hg_cmd_grep() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ '(--print0 -0)'{-0,--print0}'[end filenames with NUL]' \ '--all[print all revisions with matches]' \ '(--follow -f)'{-f,--follow}'[follow changeset or file history]' \ @@ -565,247 +609,296 @@ _hg_cmd_grep() { } _hg_cmd_heads() { - _arguments -s : $_hg_global_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_template_opts \ + '(--topo -t)'{-t,--topo}'[show topological heads only]' \ + '(--closed -c)'{-c,--closed}'[show normal and closed branch heads]' \ '(--rev -r)'{-r+,--rev=}'[show only heads which are descendants of rev]:revision:_hg_tags' } _hg_cmd_help() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ + '(--extension -e)'{-e,--extension}'[show only help for extensions]' \ + '(--command -c)'{-c,--command}'[show only help for commands]' \ + '(--keyword -k)'{-k,--keyword}'[show topics matching keyword]' \ '*:mercurial command:_hg_commands' } _hg_cmd_identify() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--rev -r)'{-r+,--rev=}'[identify the specified rev]:revision:_hg_tags' \ - '(--num -n)'{-n+,--num=}'[show local revision number]' \ - '(--id -i)'{-i+,--id=}'[show global revision id]' \ - '(--branch -b)'{-b+,--branch=}'[show branch]' \ - '(--tags -t)'{-t+,--tags=}'[show tags]' + '(--num -n)'{-n,--num}'[show local revision number]' \ + '(--id -i)'{-i,--id}'[show global revision id]' \ + '(--branch -b)'{-b,--branch}'[show branch]' \ + '(--tags -t)'{-t,--tags}'[show tags]' \ + '(--bookmarks -B)'{-B,--bookmarks}'[show bookmarks]' } _hg_cmd_import() { - _arguments -s : $_hg_global_opts \ - '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count:' \ + _arguments -s -S : $_hg_global_opts \ + '(--strip -p)'{-p+,--strip=}'[directory strip option for patch (default: 1)]:count' \ '(--message -m)'{-m+,--message=}'[use <text> as commit message]:text:' \ '(--force -f)'{-f,--force}'[skip check for outstanding uncommitted changes]' \ + '--bypass[apply patch without touching the working directory]' \ + '--no-commit[do not commit, just update the working directory]' \ + '--partial[commit even if some hunks fail]' \ + '--exact[abort if patch would apply lossily]' \ + '--import-branch[use any branch information in patch (implied by --exact)]' \ + '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ + '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ + '(--similarity -s)'{-s+,--similarity=}'[guess renamed files by similarity (0<=s<=100)]:similarity' \ '*:patch:_files' } _hg_cmd_incoming() { - _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_template_opts $_hg_subrepos_opts \ '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \ '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ '(--patch -p)'{-p,--patch}'[show patch]' \ - '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision:_hg_tags' \ + '*'{-r+,--rev=}'[a remote changeset intended to be added]:revision:_hg_tags' \ '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \ '--bundle[file to store the bundles into]:bundle file:_files' \ ':source:_hg_remote' } _hg_cmd_init() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ ':dir:_files -/' } _hg_cmd_locate() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ '(--rev -r)'{-r+,--rev=}'[search repository as it stood at revision]:revision:_hg_tags' \ '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ - '(--fullpath -f)'{-f,--fullpath}'[print complete paths]' \ + '(--fullpath -f)'{-f,--fullpath}'[print complete paths from the filesystem root]' \ '*:search pattern:_hg_files' } _hg_cmd_log() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_template_opts \ '(--follow --follow-first -f)'{-f,--follow}'[follow changeset or history]' \ '(-f --follow)--follow-first[only follow the first parent of merge changesets]' \ '(--copies -C)'{-C,--copies}'[show copied files]' \ - '(--keyword -k)'{-k+,--keyword=}'[search for a keyword]:' \ - '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:' \ - '*'{-r,--rev}'[show the specified revision or range]:revision:_hg_revrange' \ + '*'{-k+,--keyword=}'[search for a keyword]:keyword' \ + '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \ + '*'{-r+,--rev=}'[show the specified revision or revset]:revision:_hg_revrange' \ '(--no-merges -M)'{-M,--no-merges}'[do not show merges]' \ '(--only-merges -m)'{-m,--only-merges}'[show only merges]' \ '(--patch -p)'{-p,--patch}'[show patch]' \ - '(--prune -P)'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_tags' \ + '*'{-P+,--prune=}'[do not display revision or any of its ancestors]:revision:_hg_tags' \ '*:files:_hg_files' } _hg_cmd_manifest() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ + '--all[list files from all revisions]' \ ':revision:_hg_tags' } _hg_cmd_merge() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \ '(--force -f)'{-f,--force}'[force a merge with outstanding changes]' \ - '(--rev -r 1)'{-r,--rev}'[revision to merge]:revision:_hg_mergerevs' \ + '(--rev -r 1)'{-r+,--rev=}'[revision to merge]:revision:_hg_mergerevs' \ '(--preview -P)'{-P,--preview}'[review revisions to merge (no merge is performed)]' \ ':revision:_hg_mergerevs' } _hg_cmd_outgoing() { - _arguments -s : $_hg_global_opts $_hg_remote_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts $_hg_template_opts $_hg_subrepos_opts \ '(--no-merges -M)'{-M,--no-merges}'[do not show merge revisions]' \ '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ '(--patch -p)'{-p,--patch}'[show patch]' \ - '(--rev -r)'{-r+,--rev=}'[a specific revision you would like to push]' \ + '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_tags' \ '(--newest-first -n)'{-n,--newest-first}'[show newest record first]' \ ':destination:_hg_remote' } _hg_cmd_parents() { - _arguments -s : $_hg_global_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_template_opts \ '(--rev -r)'{-r+,--rev=}'[show parents of the specified rev]:revision:_hg_tags' \ ':last modified file:_hg_files' } _hg_cmd_paths() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ ':path:_hg_paths' } +_hg_cmd_phase() { + _arguments -s -S : $_hg_global_opts \ + '(--public -p --draft -d --secret -s)'{-p,--public}'[set changeset phase to public]' \ + '(--public -p --draft -d --secret -s)'{-d,--draft}'[set changeset phase to draft]' \ + '(--public -p --draft -d --secret -s)'{-s,--secret}'[set changeset phase to secret]' \ + '(--force -f)'{-f,--force}'[allow to move boundary backward]' \ + '*'{-r+,--rev=}'[target revision]:revision:_hg_tags' \ + '*:revision:_hg_tags' +} + _hg_cmd_pull() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ '(--force -f)'{-f,--force}'[run even when the remote repository is unrelated]' \ '(--update -u)'{-u,--update}'[update to new tip if changesets were pulled]' \ - '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision:' \ + '(--rev -r)'{-r+,--rev=}'[a specific revision up to which you would like to pull]:revision' \ ':source:_hg_remote' } _hg_cmd_push() { - _arguments -s : $_hg_global_opts $_hg_remote_opts \ + _arguments -s -S : $_hg_global_opts $_hg_remote_opts \ '(--force -f)'{-f,--force}'[force push]' \ - '(--rev -r)'{-r+,--rev=}'[a specific revision you would like to push]:revision:_hg_tags' \ + '*'{-r+,--rev=}'[a changeset intended to be included in the destination]:revision:_hg_tags' \ '*'{-B,--bookmark=}'[bookmark to push]:bookmark:_hg_bookmarks_internal' \ '*'{-b,--branch=}'[branch to push]:branch:_hg_branches_internal' \ - '--insecure[do not verify server certificate]' \ '--new-branch[allow pushing a new branch]' \ ':destination:_hg_remote' } _hg_cmd_remove() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ - '(--after -A)'{-A,--after}'[record remove that has already occurred]' \ - '(--force -f)'{-f,--force}'[remove file even if modified]' \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ + '(--after -A)'{-A,--after}'[record delete for missing files]' \ + '(--force -f)'{-f,--force}'[forget added files, delete modified files]' \ '*:file:_hg_files' } _hg_cmd_rename() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ '(--after -A)'{-A,--after}'[record a rename that has already occurred]' \ '(--force -f)'{-f,--force}'[forcibly copy over an existing managed file]' \ '*:file:_hg_files' } _hg_cmd_resolve() { - local context state line + local context state state_descr line ret=1 typeset -A opt_args - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \ + '(--all -a)'{-a,--all}'[select all unresolved files]' \ + '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \ '(--list -l --mark -m --unmark -u)'{-l,--list}'[list state of files needing merge]:*:merged files:->resolve_files' \ '(--mark -m --list -l --unmark -u)'{-m,--mark}'[mark files as resolved]:*:unresolved files:_hg_unresolved' \ - '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[unmark files as resolved]:*:resolved files:_hg_resolved' \ - '*:file:_hg_unresolved' + '(--unmark -u --list -l --mark -m)'{-u,--unmark}'[mark files as unresolved]:*:resolved files:_hg_resolved' \ + '*:file:_hg_unresolved' && ret=0 if [[ $state == 'resolve_files' ]] then _alternative 'files:resolved files:_hg_resolved' \ - 'files:unresolved files:_hg_unresolved' + 'files:unresolved files:_hg_unresolved' && ret=0 fi + + return ret } _hg_cmd_revert() { - local context state line + local context state state_descr line ret=1 typeset -A opt_args - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_dryrun_opts \ '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \ '(--rev -r)'{-r+,--rev=}'[revision to revert to]:revision:_hg_tags' \ - '--no-backup[do not save backup copies of files]' \ - '*:file:->diff_files' + '(--no-backup -C)'{-C,--no-backup}'[do not save backup copies of files]' \ + '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \ + '*:file:->diff_files' && ret=0 if [[ $state == 'diff_files' ]] then if [[ -n $opt_args[-r] ]] then - _hg_files + _hg_files && ret=0 else typeset -a status_files _hg_status mard - _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files + _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files && ret=0 fi fi + + return ret } _hg_cmd_serve() { - _arguments -s : $_hg_global_opts \ - '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file]:log file:_files' \ - '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file]:log file:_files' \ + _arguments -s -S : $_hg_global_opts $_hg_subrepos_opts \ + '(--accesslog -A)'{-A+,--accesslog=}'[name of access log file to write to]:log file:_files' \ + '(--errorlog -E)'{-E+,--errorlog=}'[name of error log file to write to]:log file:_files' \ '(--daemon -d)'{-d,--daemon}'[run server in background]' \ - '(--port -p)'{-p+,--port=}'[listen port]:listen port:' \ - '(--address -a)'{-a+,--address=}'[interface address]:interface address:' \ - '(--name -n)'{-n+,--name=}'[name to show in web pages]:repository name:' \ - '(--templates -t)'{-t,--templates}'[web template directory]:template dir:_files -/' \ - '--style[web template style]:style' \ + '(--port -p)'{-p+,--port=}'[port to listen on (default: 8000)]:listen port' \ + '(--address -a)'{-a+,--address=}'[address to listen on (default: all interfaces)]:interface address' \ + '--prefix[prefix path to serve from (default: server root)]:prefix' \ + '(--name -n)'{-n+,--name=}'[name to show in web pages (default: working directory)]:repository name' \ + '--web-conf=[name of the hgweb config file]:config file:_files' \ + '--pid-file=[name of file to write process ID to]:pid file:_files' \ + '--cmdserver[for remote clients]' \ + '(--templates -t)'{-t+,--templates=}'[web template directory]:template dir:_files -/' \ + '--style=[web template style]:style' \ '--stdio[for remote clients]' \ - '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]' + '(--ipv6 -6)'{-6,--ipv6}'[use IPv6 in addition to IPv4]' \ + '--certificate=[SSL certificate file]:certificate file:_files' } _hg_cmd_showconfig() { - _arguments -s : $_hg_global_opts \ - '(--untrusted -u)'{-u+,--untrusted=}'[show untrusted configuration options]' \ + _arguments -s -S : $_hg_global_opts \ + '(--untrusted -u)'{-u,--untrusted}'[show untrusted configuration options]' \ + '(--edit -e)'{-e,--edit}'[edit user config]' \ + '(--local -l --global -g)'{-l,--local}'[edit repository config]' \ + '(--local -l --global -g)'{-g,--global}'[edit global config]' \ ':config item:_hg_config' } _hg_cmd_status() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_subrepos_opts \ '(--all -A)'{-A,--all}'[show status of all files]' \ '(--modified -m)'{-m,--modified}'[show only modified files]' \ '(--added -a)'{-a,--added}'[show only added files]' \ '(--removed -r)'{-r,--removed}'[show only removed files]' \ '(--deleted -d)'{-d,--deleted}'[show only deleted (but tracked) files]' \ '(--clean -c)'{-c,--clean}'[show only files without changes]' \ - '(--unknown -u)'{-u,--unknown}'[show only unknown files]' \ + '(--unknown -u)'{-u,--unknown}'[show only unknown (not tracked) files]' \ '(--ignored -i)'{-i,--ignored}'[show ignored files]' \ '(--no-status -n)'{-n,--no-status}'[hide status prefix]' \ '(--copies -C)'{-C,--copies}'[show source of copied files]' \ '(--print0 -0)'{-0,--print0}'[end filenames with NUL, for use with xargs]' \ - '--rev[show difference from revision]:revision:_hg_tags' \ + '*--rev=[show difference from revision]:revision:_hg_tags' \ + '--change=[list the changed files of a revision]:revision:_hg_tags' \ '*:files:_files' } +_hg_cmd_summary() { + _arguments -s -S : $_hg_global_opts \ + '--remote[check for push and pull]' +} + _hg_cmd_tag() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--local -l)'{-l,--local}'[make the tag local]' \ - '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message:' \ - '(--date -d)'{-d+,--date=}'[record datecode as commit date]:date code:' \ - '(--user -u)'{-u+,--user=}'[record user as commiter]:user:' \ + '(--message -m)'{-m+,--message=}'[message for tag commit log entry]:message' \ + '(--date -d)'{-d+,--date=}'[record the specified date as commit date]:date' \ + '(--user -u)'{-u+,--user=}'[record the specified user as committer]:user' \ '(--rev -r)'{-r+,--rev=}'[revision to tag]:revision:_hg_tags' \ + '(--force -f)'{-f,--force}'[force tag]' \ + '--remove[remove a tag]' \ ':tag name:' } _hg_cmd_tip() { - _arguments -s : $_hg_global_opts $_hg_style_opts \ + _arguments -s -S : $_hg_global_opts $_hg_template_opts \ '(--patch -p)'{-p,--patch}'[show patch]' } _hg_cmd_unbundle() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--update -u)'{-u,--update}'[update to new tip if changesets were unbundled]' \ - ':files:_files' + '*:files:_files' } _hg_cmd_update() { - _arguments -s : $_hg_global_opts \ - '(--clean -C)'{-C,--clean}'[overwrite locally modified files]' \ + _arguments -s -S : $_hg_global_opts $_hg_mergetool_opts \ + '(--clean -C)'{-C,--clean}'[discard uncommitted changes (no backup)]' \ + '(--check -c)'{-c,--check}'[require clean working directory]' \ + '(--date -d)'{-d+,--date=}'[tipmost revision matching date]:date' \ '(--rev -r)'{-r+,--rev=}'[revision]:revision:_hg_tags' \ ':revision:_hg_tags' } # HGK _hg_cmd_view() { - _arguments -s : $_hg_global_opts \ - '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:' \ + _arguments -s -S : $_hg_global_opts \ + '(--limit -l)'{-l+,--limit=}'[limit number of changes displayed]:limit' \ ':revision range:_hg_tags' } @@ -859,35 +952,35 @@ _hg_qseries_opts=( '(--summary -s)'{-s,--summary}'[print first line of patch header]') _hg_cmd_qapplied() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_qdelete() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--keep -k)'{-k,--keep}'[keep patch file]' \ '*'{-r+,--rev=}'[stop managing a revision]:applied patch:_hg_revrange' \ '*:unapplied patch:_hg_qdeletable' } _hg_cmd_qdiff() { - _arguments -s : $_hg_global_opts $_hg_pat_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts \ '*:pattern:_hg_files' } _hg_cmd_qfold() { - _arguments -s : $_hg_global_opts $_h_commit_opts \ + _arguments -s -S : $_hg_global_opts $_h_commit_opts \ '(--keep -k)'{-k,--keep}'[keep folded patch files]' \ '*:unapplied patch:_hg_qunapplied' } _hg_cmd_qgoto() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--force -f)'{-f,--force}'[overwrite any local changes]' \ ':patch:_hg_qseries' } _hg_cmd_qguard() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--list -l)'{-l,--list}'[list all patches and guards]' \ '(--none -n)'{-n,--none}'[drop all guards]' \ ':patch:_hg_qseries' \ @@ -895,12 +988,12 @@ _hg_cmd_qguard() { } _hg_cmd_qheader() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ ':patch:_hg_qseries' } _hg_cmd_qimport() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--existing -e)'{-e,--existing}'[import file in patch dir]' \ '(--name -n 2)'{-n+,--name=}'[patch file name]:name:' \ '(--force -f)'{-f,--force}'[overwrite existing files]' \ @@ -909,17 +1002,17 @@ _hg_cmd_qimport() { } _hg_cmd_qnew() { - _arguments -s : $_hg_global_opts $_hg_commit_opts \ + _arguments -s -S : $_hg_global_opts $_hg_commit_opts \ '(--force -f)'{-f,--force}'[import uncommitted changes into patch]' \ ':patch:' } _hg_cmd_qnext() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_qpop() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--all -a :)'{-a,--all}'[pop all patches]' \ '(--name -n)'{-n+,--name=}'[queue name to pop]:' \ '(--force -f)'{-f,--force}'[forget any local changes]' \ @@ -927,11 +1020,11 @@ _hg_cmd_qpop() { } _hg_cmd_qprev() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_qpush() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--all -a :)'{-a,--all}'[apply all patches]' \ '(--list -l)'{-l,--list}'[list patch name in commit text]' \ '(--merge -m)'{-m+,--merge=}'[merge from another queue]:' \ @@ -941,20 +1034,20 @@ _hg_cmd_qpush() { } _hg_cmd_qrefresh() { - _arguments -s : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \ + _arguments -s -S : $_hg_global_opts $_hg_pat_opts $_hg_commit_opts \ '(--git -g)'{-g,--git}'[use git extended diff format]' \ '(--short -s)'{-s,--short}'[short refresh]' \ '*:files:_hg_files' } _hg_cmd_qrename() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ ':patch:_hg_qseries' \ ':destination:' } _hg_cmd_qselect() { - _arguments -s : $_hg_global_opts \ + _arguments -s -S : $_hg_global_opts \ '(--none -n :)'{-n,--none}'[disable all guards]' \ '(--series -s :)'{-s,--series}'[list all guards in series file]' \ '--pop[pop to before first guarded applied patch]' \ @@ -963,24 +1056,26 @@ _hg_cmd_qselect() { } _hg_cmd_qseries() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts \ + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts \ '(--missing -m)'{-m,--missing}'[print patches not in series]' } _hg_cmd_qunapplied() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_qtop() { - _arguments -s : $_hg_global_opts $_hg_qseries_opts + _arguments -s -S : $_hg_global_opts $_hg_qseries_opts } _hg_cmd_strip() { - _arguments -s : $_hg_global_opts \ - '(--force -f)'{-f,--force}'[force multi-head removal]' \ - '(--backup -b)'{-b,--backup}'[bundle unrelated changesets]' \ - '(--nobackup -n)'{-n,--nobackup}'[no backups]' \ - ':revision:_hg_tags' + _arguments -s -S : $_hg_global_opts \ + '*'{-r+,--rev=}'[revision]:revision:_hg_tags' \ + '(--force -f)'{-f,--force}'[force removal of changesets, discard uncommitted changes (no backup)]' \ + '--no-backup[no backups]' \ + '(--keep -k)'{-k,--keep}'[do not modify working directory during strip]' \ + '*'{-B+,--bookmark=}'[remove revs only reachable from given bookmark]:bookmark:_hg_bookmarks_internal' \ + '*:revision:_hg_tags' } _hg "$@" diff --git a/Completion/Unix/Command/_hostname b/Completion/Unix/Command/_hostname new file mode 100644 index 000000000..40a3189ae --- /dev/null +++ b/Completion/Unix/Command/_hostname @@ -0,0 +1,76 @@ +#compdef hostname + +local variant=$OSTYPE ret=1 +local -a context line state state_descr args aopts=( -A '-*' ) +local -A opt_args + +# May be overridden below +args=( '(-4 -6 -d -f -i -r -s)1: :_guard "^-*" "host name"' ) + +# On badly behaved systems it may be dangerous to call `hostname --help` or +# similar, so for now we'll avoid _pick_variant and just trust this. In the +# future, we should replace this by a method that can safely detect Solaris, +# BusyBox, etc. (@todo) +[[ $OSTYPE == linux* ]] && +(( $+commands[nisdomainname] || $+commands[ypdomainname] )) && +variant+=-net-tools + +case $variant in + *-net-tools) + aopts=( ) + args=( + '(: * -)'{-h,--help}'[display help information]' + '(: * -)'{-V,--version}'[display version information]' + + '(g)' # Get + '(: gs s)'{-A,--all-fqdns}'[display FQDNs resolved from network interface addresses]' + '(: gs s)'{-d,--domain}'[display DNS domain only]' + '(: gs s)'{-f,--fqdn,--long}'[display host name with DNS domain (FQDN)]' + '(: gs s)'{-i,--ip-address}'[display IP addresses for host (via DNS resolution)]' + '(: gs s)'{-I,--all-ip-addresses}'[display IP addresses for host (via network interfaces)]' + '(: gs s)'{-s,--short}'[display short host name only]' + + '(gs)' # Get/set + '(g)'{-y,--yp,--nis}'[display NIS domain only]' + + s # Set + '(-b --boot g)'{-b,--boot}'[always set a host name]' + '(: -F --file g)'{-F+,--file=}'[read host name to set from specified file]: :_files' + + o + '(-F --file g)1: :->host-or-domain' + ) + ;; + darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( + '(: -4 -6 -d -f)-s[display short host name only]' + ) + ;| # MATCH AGAIN + darwin*|freebsd*) + args+=( + '(: -d -s)-f[display host name with DNS domain (FQDN)]' + ) + ;| # MATCH AGAIN + freebsd*) + args+=( + '(: -f -s)-d[display DNS domain only]' + ) + ;; + dragonfly*) + args+=( + '(: -6 -r)-4[use first IPv4 address on interface (with -i)]' + '(: -4 -r)-6[use first IPv6 address on interface (with -i)]' + '(: -r)-i+[retrieve host name via specified interface]: :_net_interfaces' + '(: -4 -6 -i)-r+[retrieve host name via specified IP address]: :_bind_addresses' + ) + ;; +esac + +_arguments -s -S $aopts : $args && ret=0 + +[[ $state == host-or-domain ]] && { + [[ -prefix -* ]] || + if [[ -n ${opt_args[(i)*-(-y|--yp|--nis)]} ]]; then + _message -e nis-domains 'NIS domain' && ret=0 + else + _message -e host-names 'host name' && ret=0 + fi +} + +return ret diff --git a/Completion/Unix/Command/_ifconfig b/Completion/Unix/Command/_ifconfig index 0c81bce10..c5b5af8d4 100644 --- a/Completion/Unix/Command/_ifconfig +++ b/Completion/Unix/Command/_ifconfig @@ -25,11 +25,16 @@ case $OSTYPE in '(-l -C)-m[list supported media]' '(-l -C)-L[show address lifetime as time offset]' ) - opts=( $alias $debug + listopts=( + active caps chan countries mac mesh regdomain roam txparam txpower + scan sta wme + ) + opts=( $alias $debug $listopts anycast lladdr media {,-}mediaopt {,delete}tunnel create destroy {,un}plumb vlan {,-}vlandev metric prefixlen range phase ssid muid stationname channel authmode {,-}powersave powersavesleep wepmode - {,-}wep {,-}nwkey add delete ether {,-}link{0,1,2} + {,-}wep {,-}nwkey add delete ether {,-}link{0,1,2} list wme wmm + roam roam:rssi roam:rate roaming ) ;; irix5*) opts=( $debug ) ;; diff --git a/Completion/Unix/Command/_install b/Completion/Unix/Command/_install index f5056b5d0..80a1b0c00 100644 --- a/Completion/Unix/Command/_install +++ b/Completion/Unix/Command/_install @@ -11,7 +11,7 @@ common_args=( '(-C -c --compare)-c[copy files (default)]' '(-d --directory)'{-d,--directory}'[create directories]' '(-g --group)'{-g+,--group=}'[specify destination file group]: :_groups' - '(-m --mode)'{-m+,--mode=}'[specify destination file mode]: :_modes' + '(-m --mode)'{-m+,--mode=}'[specify destination file mode]: :_file_modes' '(-o --owner)'{-o+,--owner=}'[specify destination file owner]: :_users' '(-p --preserve-timestamps)'{-p,--preserve-timestamps}'[preserve modification times]' '(-s --strip)'{-s,--strip}'[strip binaries]' @@ -41,7 +41,7 @@ else args+=( ${common_args##((#s)|*\))(\*|)--*} '-B+[specify backup suffix for -b]:backup suffix' - '-f+[specify destination file flags]: :_flags' + '-f+[specify destination file flags]: :_file_flags' ) [[ $OSTYPE == dragonfly* ]] && args+=( '!-D+[no effect (compatibility with NetBSD)]: :_directories' diff --git a/Completion/Unix/Command/_jq b/Completion/Unix/Command/_jq index 55bb93c04..4ff05dab4 100644 --- a/Completion/Unix/Command/_jq +++ b/Completion/Unix/Command/_jq @@ -31,4 +31,4 @@ _arguments -S -s : \ '*--argjson[pre-set a variable to an object]: :_guard "|[A-Za-z][A-Za-z0-9]#" "variable name":value (JSON): ' \ '*--slurpfile[pre-set a variable to contents of a file]: :_guard "|[A-Za-z][A-Za-z0-9]#" "variable name":value (filename of file containing JSON):_files' \ "1: :_guard '|[^-]' filter" \ - "*:_files" + "*: :_files" diff --git a/Completion/Unix/Command/_killall b/Completion/Unix/Command/_killall index 375b1bf74..6fdb0f277 100644 --- a/Completion/Unix/Command/_killall +++ b/Completion/Unix/Command/_killall @@ -1,9 +1,77 @@ #compdef killall killall5 -if [[ $service = killall && "$OSTYPE" = (linux*|*bsd*|darwin*) ]]; then - _alternative \ - 'signals:: _signals -p' \ - 'processes-names:process:{ compadd "$expl[@]" ${${${${(f)"$(_call_program processes-names ps ${${EUID/(#s)0(#e)/xa}//[0-9]#/}ho command 2> /dev/null)"//[][\(\)]/}:#(ps|COMMAND|-*)}%%\ *}:t} }' -else +if [[ $service = killall5 || $OSTYPE != (linux|*bsd|dragonfly|darwin)* ]]; then _signals -p + return +fi + +typeset -a opts args +[[ $EUID = 0 || $_comp_priv_prefix[1] = sudo ]] && opts=( -a ) + +if _pick_variant psmisc=PSmisc unix --version; then + + local curcontext=$curcontext state state_descr line ret=1 + typeset -A opt_args + args=( + '(-e --exact)'{-e,--exact}'[require exact match for names longer than 15 chars]' + '(-I --ignore-case)'{-I,--ignore-case}'[do case insensitive process name match]' + '(-g --process-group)'{-g,--process-group}'[kill the process group to which the process belongs]' + '(-i --interactive)'{-i,--interactive}'[interactively ask for confirmation before killing]' + '(- : *)'{-l,--list}'[list all known signal names]' + '(-n --ns)'{-n+,--ns=}'[match against the PID namespace of the given PID]: : _pids' + '(-o --older-than)'{-o+,--older-than=}'[match only processes older than the specified time]:time:->time' + '(-q --quiet)'{-q,--quiet}'[do not complain if no processes were killed]' + '(-r --regexp)'{-r,--regexp}'[interpret process name as extended regular expression]' + '(1 -s --signal)'{-s+,--signal=}'[send the specified signal]: : _signals' + '(-u --user)'{-u+,--user=}'[kill only processes owned by specified user]: : _users' + '(-v --verbose)'{-v,--verbose}'[report if the signal was successfully sent]' + '(-w --wait)'{-w,--wait}'[wait for all killed processes to die]' + '(- : *)'{-V,--version}'[display version information]' + '(-y --younger-than)'{-y+,--younger-than=}'[match only processes younger than the specified time]:time:->time' + "1: : _alternative 'signals: :_signals -p' 'processes-names: :_process_names $opts'" + "*: :_process_names $opts" + ) + [[ $CURRENT = 2 || ( $CURRENT = 3 && $words[2] = (-Z|--context) ) ]] && \ + args+=( '(-Z --context)'{-Z+,--context=}'[specify SELinux security context]:regex pattern: ' ) + + _arguments -s -S -C : $args && ret=0 + + case $state in + (time) + local -a units=( 's:seconds' 'm:minutes' 'h:hours' 'd:days' + 'w:weeks' 'M:months' 'y:years' ) + if compset -P '[0-9]##(|.[0-9]#)'; then + _alternative 'float-numbers:: _message "float number"' \ + 'units:: _describe unit units' && ret=0 + else + _message 'float number and unit' && ret=0 + fi + ;; + esac + + return ret + +else # bsd and darwin + + if [[ $OSTYPE == (freebsd|dragonfly)* ]]; then + args=( '-j+[kill processes in specified jail]: :_jails -0' ) + opts+=( -t ) # long process names must be truncated + fi + args+=( + '-v[be more verbose about what will be done]' + '-e[use effective user ID for -u option]' + '(- : *)-help[give a help on command usage and exit]' + '(- : *)-l[list names of available signals and exit]' + '-m[interpret specified name as a regular expression]' + '-s[show only what will be done, but do not send any signal]' + '-d[print info about processes matched, but do not send any signal]' + '-u+[limit to processes belonging to specified user]: : _users' + '-t+[limit to processes running on specified tty]: :_ttys -od' + "-c+[with -u or -t, limit to processes matching specified name]: :_process_names $opts" + '-z[do not skip zombies]' + "*: :_process_names $opts" + + '(signal)' -$signals[2,-3] + ) + _arguments -s -S -A '-*' : $args + fi diff --git a/Completion/Unix/Command/_ldd b/Completion/Unix/Command/_ldd index 19b8a9105..1de1659a5 100644 --- a/Completion/Unix/Command/_ldd +++ b/Completion/Unix/Command/_ldd @@ -1,6 +1,6 @@ #compdef ldd -if _pick_variant gnu='(GNU|EGLIBC|Gentoo)' unix --version; then +if _pick_variant gnu='(Free Soft|GNU|EGLIBC|Gentoo)' unix --version; then args=( '(- *)--version[display version information]' '(- *)--help[display help information]' diff --git a/Completion/Unix/Command/_lldb b/Completion/Unix/Command/_lldb index 16e346cfb..0426f69f2 100644 --- a/Completion/Unix/Command/_lldb +++ b/Completion/Unix/Command/_lldb @@ -2,7 +2,8 @@ local curcontext=$curcontext state state_descr line expl ret=1 typeset -A opt_args -local -a args +typeset -a opts args +[[ $EUID = 0 || $_comp_priv_prefix[1] = sudo ]] && opts=( -a ) args=( '*'{-o+,--one-line=}'[run one-line lldb command after loading executable]:lldb command: ' @@ -29,7 +30,7 @@ args=( '(-c --core)'{-c+,--core=}'[specify core file to open]:core file:_files -g "*core*(-.)"' '*::executable and arguments:->exe_args' - name - '(-n --attach-name)'{-n+,--attach-name=}'[attach to the named process]:process name' + '(-n --attach-name)'{-n+,--attach-name=}"[attach to the named process]: :_process_names $opts" '(-w --wait-for)'{-w,--wait-for}'[wait for the specified process to launch]' - pid '(-p --attach-pid)'{-p+,--attach-pid=}'[attach to the specified process]:pid:_pids' diff --git a/Completion/Unix/Command/_lua b/Completion/Unix/Command/_lua new file mode 100644 index 000000000..7254d3819 --- /dev/null +++ b/Completion/Unix/Command/_lua @@ -0,0 +1,63 @@ +#compdef lua -P lua[0-9.-]## + +# Complete lua library names. We go out of our way here to support sub-modules +# (of the format foo.bar.baz), even though the way `lua -l` handles those isn't +# very nice, because it might be useful for informational purposes +(( $+functions[_lua_libraries] )) || +_lua_libraries() { + local p pre + local -a tmp tmp2 + + # Get Lua's library search path + tmp=( ${(s<;>)${(@f)"$( + _call_program library-path $words[1] -e '"print(package.path)"' + )"}} ) + # Support C modules, which aren't explicitly included in the above + tmp+=( ${(@)${(@M)tmp:#*'?.lua'}/%.lua/.so} ) + + for p in ${(@u)tmp}; do + # Don't recurse infinitely into the current directory; we'll just trust + # that all other paths are sensible + if [[ $p == './?'* ]]; then + tmp=( ${~${${(b)p}/'\?'/'*'}}(#qN) ) + else + tmp=( ${~${${(b)p}/'\?'/'**/*'}}(#qN) ) + fi + tmp2+=( ${(@)tmp##${p%%'?'*}} ) + done + + tmp=( ${(@)tmp2%%(/init.lua|.lua|.so)} ) + tmp=( ${(@u)${(@)tmp//\//.}} ) + + _wanted -x libraries expl 'Lua library' compadd -a "$@" - tmp +} + +_lua() { + local ret=1 + local -a context expl line state state_descr + local -A opt_args + + # Stacking not supported, no arguments are exclusive except `-` + _arguments -S -A '-*' : \ + '*-e+[execute specified command string]:command string' \ + '-E[ignore environment variables]' \ + '-i[enter interactive mode]' \ + '*-l+[specify library or module to require]: :_lua_libraries' \ + '-v[display version information]' \ + '(1 -)-[stop argument parsing and execute script on stdin]' \ + '1:Lua script:_files' \ + '*:: :->arg' \ + && ret=0 + + [[ $state == arg ]] && + if [[ $line[1] == - ]]; then + _description files expl 'script argument' + _files "${(@)expl}" && ret=0 + else + _normal && ret=0 + fi + + return ret +} + +_lua "$@" diff --git a/Completion/Unix/Command/_luarocks b/Completion/Unix/Command/_luarocks new file mode 100644 index 000000000..363cedc8d --- /dev/null +++ b/Completion/Unix/Command/_luarocks @@ -0,0 +1,591 @@ +#compdef luarocks + +# Start of options' arguments' helpers +(( $+functions[__luarocks_command] )) || +__luarocks_command(){ + local -a commands=( + build:'build/compile a rock' + config:'query information about the LuaRocks configuration' + doc:'show documentation for an installed rock' + download:'download a specific rock file from a rocks server' + help:'help on commands' + install:'install a rock' + lint:'check syntax of a rockspec' + list:'list currently installed rocks' + make:'compile package in current directory using a rockspec' + new_version:'auto-write a rockspec for a new version of a rock' + pack:'create a rock, packing sources or binaries' + path:'return the currently configured package path' + purge:'remove all installed rocks from a tree' + remove:'uninstall a rock' + search:'query the LuaRocks servers' + show:'show information about an installed rock' + unpack:'unpack the contents of a rock' + upload:'upload a rockspec to the public rocks repository' + write_rockspec:'write a template for a rockspec file' + ) + _describe -t commands 'command' commands "$@" +} +local option_deps_modes='--deps-mode=[specify how to handle dependencies]:mode:__luarocks_deps_modes' +(( $+functions[__luarocks_deps_modes] )) || +__luarocks_deps_modes(){ + local modes=( + 'all:use all trees from the rocks_trees list for finding dependencies' + 'one:use only the current tree (possibly set with --tree)' + 'order:use trees based on order (use the current tree and all trees below it on the rocks_trees list)' + 'none:ignore dependencies altogether' + ) + _describe 'dependencies mode' modes +} +(( $+functions[__luarocks_rock_version] )) || +__luarocks_rock_version(){ + local i=2 + while [[ -n "${words[$i]}" ]]; do + if [[ ! "${words[$i]}" =~ '^-' ]]; then + case "$1" in + "external_or_local") + if [[ ! -f "${words[$i]}" ]]; then + _message -e "version for external rock ${words[$i]}" + return + else + _message -e "version for local rock ${words[$i]}" + fi + ;; + "installed") + # TODO: actually complete versions of installed rocks using the cache + # How does luarocks handles multiple versions of the same package? + # If anybody knows, please write something beautiful here + tree="$2" + if [[ -z "${tree}" ]]; then + _message -e "version for installed rock ${words[$i]}" + else + _message -e "version for installed rock ${words[$i]} on tree ${tree}" + fi + return + ;; + "new_version") + if [[ -f "${words[$i]}" ]]; then + _message -e "new version for rock ${words[$i]}" + return + fi + ;; + "new_rock") + _message -e "version for new rock ${words[$i]}" + return + ;; + esac + fi + i=$(( i + 1 )) + done +} +(( $+functions[__luarocks_lua_versions] )) || +__luarocks_lua_versions(){ + _values -s , 5.3 5.2 5.1 +} +(( $+functions[___luarocks_manually_store_cache_configs_paths] )) || +___luarocks_manually_store_cache_configs_paths(){ + user_config_path="$(_call_program user_config_path luarocks config --user-config)" + system_config_path="$(_call_program system_config_path luarocks config --system-config)" + { + print -r user_config_path=${(qq)user_config_path} + print -r system_config_path=${(qq)system_config_path} + } >! ${cache_dir}/luarocks_configs_paths +} +(( $+functions[___luarocks_manually_store_cache_configured_values] )) || +___luarocks_manually_store_cache_configured_values(){ + local default_trees=($(_call_program rock_trees luarocks config --rock-trees)) + # The following command usually gives somethins like this + # + # /home/me/.luarocks user + # /usr system + # + # We'll just use the 1st and 3rd elements in the array for the default trees + configured_user_tree="${default_trees[1]}" + configured_system_tree="${default_trees[3]}" + configured_lua_version="$(_call_program lua_ver luarocks config --lua-ver)" + { + print -r configured_lua_version=${(qq)configured_lua_version} + print -r configured_user_tree=${(qq)configured_user_tree} + print -r configured_system_tree=${(qq)configured_system_tree} + } >! ${cache_dir}/luarocks_configured_values +} +(( $+functions[___luarocks_installed_rocks_cache_policy] )) || +___luarocks_installed_rocks_cache_policy(){ + local cache_file="$1" + # Before checking the modification date of the manifests files vs the + # installed rocks cache files, we need to perform the following checks: + # - luarocks executable modification date vs modification date of cache file + # holding the default configuration files' locations + # ) if configuration files' locations were possibly changed, we need to: + # * set and cache the *possibly* new locations of the configuration files + # ) else: + # * retrieve from cache the configuration files' locations + # ) end if + # - configuration files' modification date vs modification date of cache file + # holding the values from `luarocks config --lua-ver` and `luarocks config + # --rock-trees` + # ) if the configuration files' locations were changed: + # * set and cache the values from the commands above + # ) else: + # ) if configuration files are newer: + # * set and cache the values from the commands above + # ) else: + # * retrive from cache the values of the commands above + # ) end if + # ) end if + + # Decide which directory to retrieve cache from, and ensure it exists + local cache_dir + zstyle -s ":completion:${curcontext}:" cache-path cache_dir + : ${cache_dir:=${ZDOTDIR:-$HOME}/.zcompcache} + if [[ ! -d "$cache_dir" ]]; then + [[ -e "$cache_dir" ]] && + _message "cache-dir ($cache_dir) isn't a directory\!" + fi + local where_luarocks="${commands[luarocks]}" + # luarocks_configured_values + local configured_lua_version configured_user_tree configured_system_tree + # luarocks_configs_paths + local user_config_path system_config_path + if [[ -e ${cache_dir}/luarocks_configs_paths ]]; then + if [[ ${where_luarocks} -nt ${cache_dir}/luarocks_configs_paths ]]; then + ___luarocks_manually_store_cache_configs_paths + else + . ${cache_dir}/luarocks_configs_paths + fi + else + ___luarocks_manually_store_cache_configs_paths + fi + if [[ -e ${cache_dir}/luarocks_configured_values ]]; then + if [[ ${user_config_path} -nt ${cache_dir}/luarocks_configured_values ]] || [[ ${system_config_path} -nt ${cache_dir}/luarocks_configured_values ]]; then + ___luarocks_manually_store_cache_configured_values + else + . ${cache_dir}/luarocks_configured_values + fi + else + ___luarocks_manually_store_cache_configured_values + fi + + local user_manifest_file="${configured_user_tree}/lib/luarocks/rocks-${configured_lua_version}/manifest" + local system_manifest_file="${configured_system_tree}/lib/luarocks/rocks-${configured_lua_version}/manifest" + local cache_status=1 + if [[ -f ${cache_file} ]]; then + if [[ -f ${user_manifest_file} ]]; then + if [[ ${user_manifest_file} -nt ${cache_file} ]]; then + cache_status=0 + fi + fi + if [[ -f ${system_manifest_file} ]]; then + if [[ ${system_manifest_file} -nt ${cache_file} ]]; then + cache_status=0 + fi + fi + fi + return cache_status +} +(( $+functions[__luarocks_installed_rocks] )) || +__luarocks_installed_rocks(){ + # This function optionally recieves one argument of the tree in which + # installed rocks are searched for. If this argument is used, the installed + # rocks which will be completed by this function will not use the cache which + # is valid only for installed rocks on default trees like /usr/lib/luarocks + # and ~/.luarocks + local tree="$1" + if [[ -z ${tree} ]]; then + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy ___luarocks_installed_rocks_cache_policy + fi + if _cache_invalid luarocks_installed_list; then + rocks_list=($(luarocks list --porcelain)) + _store_cache luarocks_installed_list rocks_list + else + _retrieve_cache luarocks_installed_list + fi + if [[ -z ${rocks_list} ]]; then + _message -r "no installed rocks" + return + fi + if _cache_invalid luarocks_installed_names; then + rocks_names=() + for i in {1.."${#rocks_list[@]}"..4}; do + rocks_names+=("${rocks_list[$i]}") + done + _store_cache luarocks_installed_names rocks_names + else + _retrieve_cache luarocks_installed_names + fi + if _cache_invalid luarocks_installed_versions; then + rocks_versions=() + for i in {2.."${#rocks_list[@]}"..4}; do + rocks_versions+=("${rocks_list[$i]}") + done + _store_cache luarocks_installed_versions rocks_versions + else + _retrieve_cache luarocks_installed_versions + fi + if _cache_invalid luarocks_installed_descriptions; then + rocks_descriptions=() + for i in {1.."${#rocks_names[@]}"}; do + name_version_description="$(luarocks show ${rocks_names[$i]} 2>/dev/null | head -2 | tail -1)" + total_length=${#name_version_description} + garbage_length="$((${#rocks_names[$i]} + ${#rocks_versions[$i]} + 5))" + description="${name_version_description[${garbage_length},${total_length}]}" + rocks_descriptions+=("${description}") + done + _store_cache luarocks_installed_descriptions rocks_descriptions + else + _retrieve_cache luarocks_installed_descriptions + fi + if _cache_invalid luarocks_installed_names_and_descriptions; then + rocks_names_and_descriptions=() + for i in {1.."${#rocks_names[@]}"}; do + name_and_description=${rocks_names[$i]}:${rocks_descriptions[$i]} + rocks_names_and_descriptions+=(${name_and_description}) + done + else + _store_cache luarocks_installed_names_and_descriptions rocks_names_and_descriptions + fi + else + rocks_list=($(luarocks --tree="${tree}" list --porcelain 2> /dev/null)) + if [[ -z ${rocks_list} ]]; then + _message "no installed rocks in the specified tree" + return + fi + rocks_names=() + for i in {1.."${#rocks_list[@]}"..4}; do + rocks_names+=("${rocks_list[$i]}") + done + rocks_versions=() + for i in {2.."${#rocks_list[@]}"..4}; do + rocks_versions+=("${rocks_list[$i]}") + done + rocks_descriptions=() + for i in {1.."${#rocks_names[@]}"}; do + name_version_description="$(luarocks show ${rocks_names[$i]} 2> /dev/null | head -2 | tail -1)" + total_length=${#name_version_description} + garbage_length="$((${#rocks_names[$i]} + ${#rocks_versions[$i]} + 5))" + description="${name_version_description[${garbage_length},${total_length}]}" + rocks_descriptions+=("${description}") + done + rocks_names_and_descriptions=() + for i in {1.."${#rocks_names[@]}"}; do + name_and_description=${rocks_names[$i]}:${rocks_descriptions[$i]} + rocks_names_and_descriptions+=(${name_and_description}) + done + fi + _describe 'installed rocks' rocks_names_and_descriptions +} +# Used to complete one or more of the followings: +# - .rockspec file +# - .src.rock file +# - external rock +(( $+functions[__luarocks_rock] )) || +__luarocks_rock(){ + local -a alts=() + while [[ $# -gt 0 ]]; do + arg="$1" + case "$arg" in + (rockspec) + alts+=('files:rock file:_files -g "*.rockspec(-.)"') + shift 1 + continue + ;; + (rockpack) + alts+=(':rock file:{_files -g "*.src.rock(-.)"}') + shift 1 + continue + ;; + (external) + alts+=(':external rock:') + shift 1 + continue + ;; + (installed) + tree="$2" + alts+=(":local rock:{__luarocks_installed_rocks ${tree}}") + if [[ -z "${tree}" ]]; then + shift + else + shift 2 + fi + continue + ;; + esac + shift + continue + done + _alternative ${alts[@]} +} +(( $+functions[__luarocks_git_tags] )) || +__luarocks_git_tags(){ + # Copied straight from definition of _git + local expl + declare -a tags + tags=(${${(f)"$(_call_program tagrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) + __git_command_successful $pipestatus || return 1 + _wanted tags expl tag compadd -M 'r:|/=**' "$@" -a - tags +} + +# End of options' arguments' helpers & Start of sub commands helpers + +# arguments: +# - must: .rockspec file / external rock +# - optional: version (only when chossing external rock) +local make_command_options=( + '--pack-binary-rock[produce a .rock file with the contents of compilation inside the current directory instead of installing it]' + '--keep[do not remove previously installed versions of the rock after building a new one]' + '--branch=[override the `source.branch` field in the loaded rockspec]:NAME:{_message "branch name"}' +) +local build_command_options=( + "${make_command_options[@]}" + '--only-deps[installs only the dependencies of the rock]' + $option_deps_modes +) +(( $+functions[_luarocks_build] )) || +_luarocks_build(){ + _arguments -A "-*" \ + "${build_command_options[@]}" \ + '1: :{__luarocks_rock "rockspec" "external"}' \ + '2:: :{__luarocks_rock_version "external_or_local"}' +} +# arguments: +# - must: option +local config_command_options=( + '--lua-incdir[path to Lua header files]' + '--lua-libdir[path to Lua library files]' + '--lua-ver[lua version (in major.minor format)]' + '--system-config[location of the system config file]' + '--user-config[location of the user config file]' + '--rock-trees[rocks trees in useFirst the user tree, then the system tree]' +) +(( $+functions[_luarocks_config] )) || +_luarocks_config(){ + _arguments "${config_command_options[@]}" +} +# arguments: +# - must: installed rock +local doc_command_options=( + '--home[open the home page of project]' + '--list[list documentation files only]' +) +(( $+functions[_luarocks_doc] )) || +_luarocks_doc(){ + _arguments \ + "${doc_command_options[@]}" \ + '1: :{__luarocks_rock "installed" '"${opt_args[--tree]}"'}' +} +# arguments: +# - must: external only rockspec +local download_command_options=( + '--all[download all files if there are multiple matches]' + '--source[download .src.rock if available]' + '--rockspec[download .rockspec if available]' + '--arch=[download rock for a specific architecture]:ARCH:' +) +(( $+functions[_luarocks_download] )) || +_luarocks_download(){ + _arguments -A "-*" \ + "${download_command_options[@]}" \ + '1: :{__luarocks_rock "external"}' \ + '2:: :{__luarocks_rock_version "external_or_local"}' +} +# arguments: +# must: luarocks sub command +(( $+functions[_luarocks_help] )) || +_luarocks_help(){ + _arguments '1: :__luarocks_command' +} +# arguments: +# - must: .rockspec file / external rock +# - optional: version +# NOTE: it receives the same argument as the build command and it accepts the same options as well +(( $+functions[_luarocks_install] )) || +_luarocks_install(){ + _luarocks_build +} +# arguments: +# - must: rockspec file (first and last) +(( $+functions[_luarocks_lint] )) || +_luarocks_lint(){ + _arguments '1:: :{__luarocks_rock "rockspec"}' +} +# arguments: +# NOTE: receives only options +local list_command_options=( + '--outdated[list only rocks for which there is a higher version available in the rocks server]' + '--porcelain[produce machine-friendly output]' +) +(( $+functions[_luarocks_list] )) || +_luarocks_list(){ + _arguments "${list_command_options[@]}" +} +# arguments: +# - optional: rockspec file +# NOTE: it's options were already described above. +(( $+functions[_luarocks_make] )) || +_luarocks_make(){ + _arguments '1:: :{__luarocks_rock "rockspec"}' +} +# arguments: +# - optional: .rockspec file / external rock +# - optional: version (unless a --tag was given) +# - optional: URL +local new_version_command_options=( + '--tag=[if no version is specified, this option'"'"'s argument is used instead]:tag:__luarocks_git_tags' +) +(( $+functions[_luarocks_new_version] )) || +_luarocks_new_version(){ + _arguments -A "-*" \ + "${new_version_command_options[@]}" \ + '1:: :{__luarocks_rock "external" "rockspec"}' \ + '2:: :{__luarocks_rock_version "external_or_local"}' \ + '3:: :_urls' +} +# arguments: +# - must: .rockspec file / external rock +# - optional: version +(( $+functions[_luarocks_pack] )) || +_luarocks_pack(){ + _luarocks_build +} +# arguments: +# NOTE: receives only options +local path_command_options=( + '--bin[adds the system path to the output]' + '--append[appends the paths to the existing paths]' + '--lr-path[exports the Lua path (not formatted as shell command)]' + '--lr-cpath[exports the Lua cpath (not formatted as shell command)]' + '--lr-bin[exports the system path (not formatted as shell command)]' +) +(( $+functions[_luarocks_path] )) || +_luarocks_path(){ + _arguments "${path_command_options[@]}" +} +# NOTE: receives only options yet --tree is mandatory +# NOTE: --force can be used only in conjunction with --old-versions +local option_force='--force[force removing old versions when]' +local purge_command_options=( + '--old-versions[keep the highest-numbered version of each rock and remove the other ones]' + $option_force +) +(( $+functions[_luarocks_purge] )) || +_luarocks_purge(){ + _arguments "${purge_command_options[@]}" +} +# arguments: +# - must: locally installed rock +# - optional: version +local option_force_fast='--force-fast[works like --force but doesn'"'"'t reports forced removals]' +local remove_command_options=( + $option_deps_modes + $option_force + $option_force_fast +) +(( $+functions[_luarocks_remove] )) || +_luarocks_remove(){ + _arguments -A "-*" \ + "${remove_command_options[@]}" \ + '1: :{__luarocks_rock "installed" '"${opt_args[--tree]}"'}' \ + '2:: :{__luarocks_rock_version "installed" '"${opt_args[--tree]}"'}' +} +# arguments: +# - must: string as a search query +local search_command_options=( + '--source[return only rockspecs and source rocks]' + '--binary[return only pure Lua and binary rocks (rocks that can be used with the "install" command without requiring a C toolchain)]' + '--all[list all contents of the server that are suitable to this platform, do not filter by name]' +) +(( $+functions[_luarocks_search] )) || +_luarocks_search(){ + _arguments \ + "${search_command_options[@]}" \ + '*:SEARCH QUERY:' +} +# arguments: +# - must: installed rock +local show_command_options=( + '--home[home page of project]' + '--modules[all modules provided by this package as used by require()]' + '--deps[packages this package depends on]' + '--rockspec[the full path of the rockspec file]' + '--mversion[the package version]' + '--rock-tree[local tree where rock is installed]' + '--rock-dir[data directory of the installed rock]' +) +(( $+functions[_luarocks_show] )) || +_luarocks_show(){ + _arguments \ + "${show_command_options[@]}" \ + "1: :{__luarocks_rock 'installed' "${opt_args[--tree]}"}" +} +# arguments: +# - must: rockpack file / external rock +# - optional: version (only when chossing external rock) +local unpack_command_options=( + '--force[unpack files even if the output directory already exists]' +) +(( $+functions[_luarocks_unpack] )) || +_luarocks_unpack(){ + _arguments \ + "${unpack_command_options[@]}" \ + '1: :{__luarocks_rock "rockpack" "external"}' +} +# arguments: +# - must: rockspec file +local upload_command_options=( + '--skip-pack[do not pack and send source rock]' + '--api-key=[give it an API key]:KEY:{_message "api key"}' + '--force[replace existing rockspec if the same revision of a module already exists]' +) +(( $+functions[_luarocks_upload] )) || +_luarocks_upload(){ + _arguments \ + "${upload_command_options[@]}" \ + '1: :{__luarocks_rock "rockspec"}' +} +# arguments: +# - optional: name +# - optional: version +# - optional: URL / PATH +# receives as an argument a name and a version with optionally a URL/PATH +local write_rockspec_command_options=( + '--output=[write the rockspec with the given filename]:FILE:_files' + '--license=[specify a license string]:license (e.g. "MIT/X11" or "GNU GPL v3")' + '--summary=[a short one-line description summary]:summary:{_message -e "short summary of the rock"}' + '--detailed=[a longer description string]:detailed_text:{_message -e "detailed description of the rock"}' + '--homepage=[project homepage]:URL:_urls' + '--lua-version=[supported Lua versions]:LUA_VER:__luarocks_lua_versions' + '--rockspec-format=[rockspec format version, such as "1.0" or "1.1"]:VER: ' + '--tag=[tag to use. Will attempt to extract version number from it]:tag:__git_tag' + '--lib=[comma separated list of C library files to link to]:library files' +) +(( $+functions[_luarocks_write_rockspec] )) || +_luarocks_write_rockspec(){ + _arguments -A "-*" \ + "${write_rockspec_command_options[@]}" \ + '1:: :{_message "new rock name"}' \ + '2:: :{__luarocks_rock_version "new_rock"}' \ + '3:: :_urls' +} + +# The real thing +_arguments -C \ + '(--server --only-server)--server=[fetch rocks/rockspecs from this server]:HOST:_hosts' \ + '(--server --only-server)--only-server=[fetch rocks/rockspecs from this server only]:HOST:_hosts' \ + '--only-sources=[restrict downloads to paths matching the given URL]:URL:_urls' \ + '--tree=[which tree to operate on]:TREE:{_files -/}' \ + '--local[use the tree in the user'"'"'s home directory]' \ + '--verbose[display verbose output of commands executed]' \ + '--timeout=[timeout on network operations]:SECONDS:{_message "timeout (seconds)"}' \ + '1: :__luarocks_command' \ + '*::arg:->args' + +case "$state" in + (args) + curcontext="${curcontext%:*:*}:luarocks-${words[1]}:" + if [[ $? != 1 ]]; then + _call_function ret _luarocks_${words[1]} + fi +esac diff --git a/Completion/Unix/Command/_lynx b/Completion/Unix/Command/_lynx index 6c4d57f6f..d25b03975 100644 --- a/Completion/Unix/Command/_lynx +++ b/Completion/Unix/Command/_lynx @@ -1,7 +1,5 @@ #compdef lynx -# Lynx Version 2.8.7rel.1 (05 Jul 2009) - local curcontext="$curcontext" state line ret=1 typeset -A opt_args @@ -26,7 +24,9 @@ _arguments -C \ '-cmd_log=[log keystroke commands to the given file]:keystroke log:_files' \ '-cmd_script=[read keystroke commands from the given file (see -cmd_log)]:keystroke log:_files' \ '-color[forces color mode on, if available]' \ - '-connect_timeout=[set the N-second connection timeout (18000)]:connection timeout (seconds):' \ + '-collapse_br_tags[toggle collapsing of BR tags (on)]' \ + '-connect_timeout=[set the N-second connection timeout]:connection timeout (seconds) [18000]' \ + '-convert_to=[convert input]:format:_mime_types' \ '-cookie_file=[specifies a file to use to read cookies]:cookie file:_files' \ '-cookie_save_file=[specifies a file to use to store cookies]:cookie file:_files' \ '-cookies[toggles handling of Set-Cookie headers (on)]' \ @@ -34,7 +34,8 @@ _arguments -C \ '-crawl[with -traversal, output each page to a file with -dump, format output as with -traversal, but to stdout]' \ '-curses_pads[uses curses pad feature to support left/right shifting (on)]' \ '-debug_partial[incremental display stages with MessageSecs delay (off)]' \ - '-delay=[set NNN-second delay at statusline message (0.000)]:delay (seconds):' \ + '-default_colors[use terminal default foreground/background colors (on)]' \ + '-delay=[set NNN-second delay at statusline message]:delay (seconds) [0.000]' \ "-display=[set the display variable for X exec'ed programs]:display:_x_display" \ '-display_charset=[charset for the terminal output]:character set:' \ "-dont_wrap_pre[inhibit wrapping of text in <pre> when -dump'ing and -crawl'ing, mark wrapped lines in interactive session (off)]" \ @@ -47,7 +48,7 @@ _arguments -C \ '-fileversions[include all versions of files in local VMS directory listings]' \ '-force_empty_hrefless_a[force HREF-less 'A' elements to be empty (close them as soon as they are seen) (off)]' \ '-force_html[forces the first document to be interpreted as HTML (off)]' \ - '-force_secure[toggles forms-based vs old-style options menu (on)]' \ + '-force_secure[toggle forcing of the secure flag for SSL cookies (off)]' \ '-forms_options[toggles forms-based vs old-style options menu (on)]' \ '-from[toggle transmission of From headers (on)]' \ '-ftp[disable ftp access (off)]' \ @@ -57,11 +58,13 @@ _arguments -C \ '-hiddenlinks=[hidden links: options are merge, listonly, or ignore]:option:(merge listonly ignore)' \ "-historical[toggles use of '>' or '-->' as terminator for comments (off)]" \ '-homepage=[set homepage separate from start page]:URL:->html' \ + '-html5_charsets[toggle use of HTML5 charset replacements]' \ '-image_links[toggles inclusion of links for all images (off)]' \ '-index=[set the default index file to URL]:URL:->html' \ '-ismap[toggles inclusion of ISMAP links when client-side MAPs are present (off)]' \ '-justify[do justification of text (off)]' \ '-link=[starting count for lnk#.dat files produced by -crawl (0)]:starting count:' \ + '-list_inline[with -dump, show links inline with text]' \ '-listonly[with -dump, forces it to show only the list of links (off)]' \ '-localhost[disable URLs that point to remote hosts (off)]' \ '-locexec[enable local program execution from local files only (if lynx was compiled with local execution enabled)]' \ @@ -91,6 +94,7 @@ _arguments -C \ '-nostatus[disable the miscellaneous information messages (off)]' \ '-notitle[disable the title at the top of each page (off)]' \ '-nounderline[disable underline video-attribute]' \ + "-nozap=[disable checks for the 'z' key]:duration:(all initially full)" \ '-number_fields[force numbering of links as well as form input fields (off)]' \ '-number_links[force numbering of links (off)]' \ '-partial[toggles display partial pages while downloading (on)]' \ @@ -105,7 +109,7 @@ _arguments -C \ '-pseudo_inlines[toggles pseudo-ALTs for inlines with no ALT string (on)]' \ '-raw[toggles default setting of 8-bit character translations or CJK mode for the startup character set (off)]' \ '-realm[restricts access to URLs in the starting realm (off)]' \ - '-read_timeout=[set the N-second read-timeout (18000)]:timeout (seconds):' \ + '-read_timeout=[set the N-second read-timeout]:timeout (seconds) [18000]' \ '-reload[flushes the cache on a proxy server (only the first document affected) (off)]' \ '-restrictions=[use -restrictions to see list]:options:->restrictions' \ '-resubmit_posts[toggles forced resubmissions (no-cache) of forms with method POST when the documents they returned are sought with the PREV_DOC command or from the History List (off)]' \ @@ -113,6 +117,9 @@ _arguments -C \ '-scrollbar[toggles showing scrollbar (off)]' \ '-scrollbar_arrow[toggles showing arrows at ends of the scrollbar (on)]' \ '-selective[require .www_browsable files to browse directories]' \ + '-session=[resume from specified file on startup and save session to it on exit]:session file:_files' \ + '-sessionin=[resume session from specified file on startup]:session file:_files' \ + '-sessionout=[save session to specified file on exit]:session file:_files' \ '-short_url[enables examination of beginning and end of long URL in status line (off)]' \ "-show_cfg[show 'LYNX.CFG' setting (off)]" \ '-show_cursor[toggles hiding of the cursor in the lower right corner (on)]' \ @@ -131,16 +138,18 @@ _arguments -C \ '-trace[turns on Lynx trace mode (off)]' \ '-trace_mask=[customize Lynx trace mode]:trace mask:(0 1 2 3 4 5 6 7)' \ '-traversal[traverse all http links derived from startfile]' \ + '-trim_blank_lines[toggle trimming of leading/trailing/collapsed-br blank lines (on)]' \ '-trim_input_fields[trim input text/textarea fields in forms (off)]' \ '-underline_links[toggles use of underline/bold attribute for links (off)]' \ '-underscore[toggles use of _underline_ format in dumps (off)]' \ + '-unique_urls[toggle use of unique-urls setting for -dump and -listonly options (off)]' \ '-use_mouse[turn on mouse support (off)]' \ '-useragent=[set alternate Lynx User-Agent header]:user-agent header:' \ '-validate[accept only http URLs (meant for validation) implies more restrictions than -anonymous, but goto is allowed for http and https (off)]' \ '-verbose[toggles [LINK\], [IMAGE\] and [INLINE\] comments with filenames of these images (on)]' \ '(- *)-version[print Lynx version information]' \ '-vikeys[enable vi-like key movement (off)]' \ - '-width=[screen width for formatting of dumps (default is 80)]:number of columns:' \ + '-width=[specify screen width for formatting of dumps]:number of columns [80]' \ '-with_backspaces[emit backspaces in output if -dumping or -crawling]' \ '-xhtml-parsing[enable XHTML 1.0 parsing (off)]' \ ':URL:->html' && ret=0 @@ -148,12 +157,12 @@ _arguments -C \ case "$state" in restrictions) _values -s ',' 'restriction' \ - \? all bookmark bookmark_exec change_exec_perms chdir default \ - dired_support disk_save dotfiles download editor exec exec_frozen \ + \? all bookmark bookmark_exec change_exec_perms chdir compileopts_info \ + default dired_support disk_save dotfiles download editor exec exec_frozen \ externals file_url goto inside_ftp inside_news inside_rlogin \ - inside_telnet jump lynx_cgi mail multibook news_post options_save \ - outside_ftp outside_news outside_rlogin outside_telnet print shell \ - suspend telnet_port useragent && return + inside_telnet jump lynxcfg_info lynxcfg_xinfo lynxcgi mail multibook \ + news_post options_save outside_ftp outside_news outside_rlogin \ + outside_telnet print shell suspend telnet_port useragent && return ;; html) _alternative 'files:file:_files -g "*.x#html#(-.)"' 'urls:URL:_urls' && return diff --git a/Completion/Unix/Command/_lz4 b/Completion/Unix/Command/_lz4 new file mode 100644 index 000000000..d69091d00 --- /dev/null +++ b/Completion/Unix/Command/_lz4 @@ -0,0 +1,103 @@ +#compdef lz4 lz4c lz4c32 lz4cat unlz4 + +# Notes: +# - All lz4 CLI tools take the same options — you can do `unlz4 --compress` if +# you want — and we complete accordingly. One can make a reasonable argument +# that we shouldn't, but...? +# - The only exceptions to the above are the legacy compression options (-c0, +# -hc, and so on) — only lz4c accepts these. Each of these options is +# interpreted separately otherwise (e.g., -c0 becomes equivalent to -c -0) +# - All these tools use a non-standard option-handling method that we don't +# fully support. For example, the tool will let you do things like `-b1e3i3` +# instead of `-b1 -e3 -i3` — we won't + +local ret=1 +local -a context line state state_descr expl args levels=( -{1..16} ) +local -A opt_args val_args + +args=( + + excl # Fully exclusive options + '(: -)'{-h,--help}'[display help information]' + '(: -)-H[display long help information]' + '(: -)'{-V,--version}'[display version information]' + + misc # Misc. arguments + '(-q -v --quiet --verbose)*'{-q,--quiet}'[reduce output verbosity]' + '(-q -v --quiet --verbose)*'{-v,--verbose}'[increase output verbosity]' + '*::: :->files' + + B # Benchmark/compress-mode options (not allowed with legacy format) + '(d t -l)*-B-[specify block property]: :->block-props' + '(d t -l --no-content-size)--content-size[record original uncompressed size]' + '(d t -l --no-frame-crc)--frame-crc[enable content checksum]' + '(d t -l --content-size)--no-content-size[do not record original uncompressed size]' + '(d t -l --frame-crc)--no-frame-crc[disable content checksum]' + '(d t -l --sparse)--no-sparse[disable sparse-file support]' + '(d t -l --no-sparse)--sparse[enable sparse-file support]' + + C # Compress/decompress-mode options + '(b t -c --stdout --to-stdout)'{-c,--stdout}'[write on standard output]' + '(b t -y)'{-f,--force}'[overwrite target without prompting, or cat on standard output]' + '(b t -k --keep --rm)'{-k,--keep}'[keep source file]' + '(b t -m -r --multiple)'{-m,--multiple}'[take multiple input files]' + '!(b -t -f -y --force)--no-force' + '(b t -m --multiple)-r[operate recursively on directories]' + '(b t -k --keep)--rm[remove source file]' + '!(b t -c --stdout)--to-stdout' + + b # Benchmark-mode options + "(C c d t)-b-[benchmark file using specified compression level]::compression level:(${(j< >)levels//-/})" + "(C c d t)-e-[specify upper compression level limit (with -b)]:compression level:(${(j< >)levels//-/})" + '(C c d t)-i-[specifiy minimum evaluation time (with -b)]:evaluation time (seconds)' + + c # Compress-mode options + "(b d t ${(j< >)levels} -c0 -c1 -c2 -hc)"${^levels} + '(B b d t -m -r --multiple)-l[compress using legacy (Linux kernel) format]' + '(b d t -z --compress)'{-z,--compress}'[compress file]' + + d # Decompress-mode options + '(B b c d t)'{-d,--decompress}'[decompress file]' + '!(B b c d t)--uncompress' + + t # Test-mode options + '(B C b c d t)'{-t,--test}'[test integrity of compressed file]' +) +[[ $service == lz4c ]] && args+=( + + l # Legacy compress-mode options (not to be confused with the legacy format) + "(b d t ${(j< >)levels} -c1 -c2 -hc)-c0[use fast compression (like -0)]" + "(b d t ${(j< >)levels} -c0 -c2 -hc)-c1[use high compression (like -9)]" + "(b d t ${(j< >)levels} -c0 -c1 -c2 -hc)"{-c2,-hc}'[use very high compression (like -12)]' + '(b t -f --force)-y[overwrite target without prompting]' +) + +_arguments -s -S : $args && ret=0 + +case $state in + block-props) + # The usage help indicates that the use of an explicit byte value (-B32 or + # greater) is only for benchmarking, and indeed when such a value is given + # the tool prints a message prefixed with 'bench:'... but there is nothing + # that actually restricts this to the benchmark mode, so...? + _values 'predefined block property or block size in bytes (32+)' \ + '4[set block size to 64 KiB]' \ + '5[set block size to 256 KiB]' \ + '6[set block size to 1 MiB]' \ + '7[set block size to 4 MiB]' \ + 'D[enable block dependency]' \ + 'X[enable block checksum]' \ + && ret=0 + ;; + files) + if + (( CURRENT == 1 )) || + [[ -n ${opt_args[(i)*-(-b|-m|-r|--multiple)]} ]] + then + if [[ -n ${opt_args[(i)*--r]} ]]; then + _description files expl 'input file or directory' + else + _description files expl 'input file' + fi + _files "${(@)expl}" && ret=0 + elif (( CURRENT == 2 )); then + _description files expl 'output file' + _files "${(@)expl}" && ret=0 + else + _message 'no more arguments' && ret=0 + fi + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index 1761bba71..e23906373 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -177,7 +177,7 @@ _make() { '(- *)'{-h,--help}'[print help message and exit]' '(-i --ignore-errors)'{-i,--ignore-errors}'[ignore errors from recipes]' '*'{-I,--include-dir=}'[search DIRECTORY for included makefiles]:search path for included makefile:->dir' - '(-j --jobs)'{-j,--jobs=}'[allow N jobs at once; infinite jobs with no arg]:number of jobs' + '(-j --jobs)'{-j+,--jobs=}'[allow N jobs at once; infinite jobs with no arg]:number of jobs' '(-k --keep-going)'{-k,--keep-going}"[keep going when some targets can't be made]" '(-l --load-average --max-load)'{-l,--load-average=,--max-load}"[don't start multiple jobs unless load is below N]:load" '(-L --check-symlink-times)'{-L,--check-symlink-times}'[use the latest mtime between symlinks and target]' diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index 67810e1dc..41ae85a1f 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -1,16 +1,174 @@ #compdef man apropos whatis +# Notes: +# - Solaris is seemingly the only OS that doesn't allow the `man n page` syntax; +# you must use `man -s n page` +# - We assume that Linux distributions are using either man-db or mandoc +# - @todo Would be nice to support completing the initial operand as a section +# name (on non-Solaris systems) +# - @todo We don't support the man-db syntax <name>.<section> (e.g., `ls.1`) +# - @todo We don't support the man-db feature of 'sub-pages' — that is, treating +# pairs of operands like `git diff` as `git-diff` +# - @todo Option exclusivity isn't super accurate +# - @todo Solaris man accepts a single hyphen as the first option to disable +# paging (like AIX's -c); we don't support that +# - @todo Linux apropos/whatis take options; we don't complete them yet + _man() { - local dirs expl mrd awk + local dirs expl mrd awk variant noinsert + local -a context line state state_descr args modes + local -aU sects + local -A opt_args val_args sect_descs - if (( $words[(I)-M] == (( $CURRENT - 1 )) )); then - _directories && return 0 - fi + if [[ $service == man ]]; then + # We'll treat all mandoc-based systems (Alpine, various Illumos distros, + # etc.) as OpenBSD + _pick_variant -r variant openbsd='-S subsection' $OSTYPE --- + + modes=( + -f -K -k -l -R -w -W + --apropos + --global-apropos + --local-file + --location + --location-cat + --recode + --whatis + --where + --where-cat + ) + [[ $variant == darwin* ]] && modes+=( -t ) - if [[ $service == man ]] && (( $words[(I)-l] + $words[(I)--local-file] )); then - _files || return 0 + args=( + "(${(j< >)modes})"{-f,--whatis}'[display short description (like whatis)]' + "(${(j< >)modes})"{-k,--apropos}'[search for keyword (like apropos)]' + '(-M --manpath)'{-M+,--manpath=}'[specify manual search path]:manual search path:_sequence -s\: _directories' + ) + if [[ $variant == (darwin|dragonfly|freebsd|linux)* ]]; then + args+=( + '(-a -S -s --all --sections)'{-a,--all}'[display all matching pages]' + '(-P --pager)'{-P+,--pager=}'[specify output pager]:pager:_path_commands' + # @todo Could enumerate these + '(-p --preprocessor)'{-p+,--preprocessor=}'[specify roff preprocessor sequence]:preprocessor sequence' + ) + else + args+=( '(-s)-a[display all matching pages]' ) + fi + [[ $variant == (aix|solaris)* ]] || args+=( + '(-C --config-file)'{-C+,--config-file=}'[specify configuration file]:configuration file:_files' + "(${(j< >)modes})"{-w,--path,--where}'[display file locations]' + ) + [[ $variant == (aix|netbsd|openbsd)* ]] || args+=( + # @todo FreeBSD allows this to be given multiple times + '(-d --debug)'{-d,--debug}'[display debugging information]' + ) + [[ $variant == (darwin|dragonfly|freebsd|linux|solaris|aix)* ]] && args+=( + '(-7 -H -t --ascii --html --troff)'{-t,--troff}'[format man page using troff]' + ) + [[ $variant == (darwin|linux)* ]] && args+=( + "(${(j< >)modes})"{-K,--global-apropos}'[search for keyword in all pages]' + '(-m --systems)'{-m+,--systems=}'[search manual of specified system]:operating system' + ) + [[ $variant == (darwin|dragonfly|freebsd)* ]] && args+=( + '(: -)-h[display help information]' + '(-a)-S+[specify manual sections to search]: :->sects' + ) + [[ $variant == (dragonfly|freebsd)* ]] && args+=( + # @todo Could enumerate these + '-m[search manual of specified architecture]:architecture' + '-o[use non-localized man pages]' + ) + [[ $variant == (netbsd|openbsd)* ]] && args+=( + '-c[disable paging]' + '-m[augment manual search path]:manual search path:_sequence -s\: _directories' + '(-a)-s+[specify manual section to search]: :->sects' + ) + [[ $variant == linux* ]] && args+=( + '(: -)'{-\?,--help}'[display help information]' + '(-7 -t -H -T -Z --ascii --html --troff --troff-device --ditroff)'{-7,--ascii}'[translate man pages for 7-bit terminal]' + '(-D --default)'{-D,--default}'[reset man to default options]' + # @todo Could enumerate these + '(-E --encoding)'{-E+,--encoding=}'[specify output encoding]:encoding' + '(-e --extension)'{-e+,--extension=}'[specify sub-extension]:sub-extension' + '(-H --html)'{-H-,--html=-}'[produce HTML output for specified browser]::Web browser:_path_commands' + '(-i -I --ignore-case --match-case)'{-i,--ignore-case}'[search case-insensitively]' + '(-i -I --ignore-case --match-case)'{-I,--match-case}'[search case-sensitively]' + '(-L --locale)'{-L+,--locale=}'[specify locale]:locale:_locales' + "(${(j< >)modes})"{-l+,--local-file=}'[format and display specified file]:*:::manual file:_files' + "!(${(j< >)modes})"{--location,--location-cat} + '--names-only[match only page names (with --regex or --wildcard)]' + '(--nh --no-hyphenation)'{--nh,--no-hyphenation}'[disable hyphenation]' + '(--nj --no-justification)'{--nj,--no-justification}'[disable justification]' + '--no-subpages[do not combine pairs of page names into single page name]' + # @todo Could enumerate these + "(${(j< >)modes})"{-R+,--recode=}'[output man page in specified encoding]:encoding' + '(-r --prompt)'{-r+,--prompt=}'[specify prompt for less]:less prompt' + '(-a --all --wildcard)--regex[treat page name as regular expression]' + '(-a -S -s --all --sections)'{-S+,-s+,--sections=}'[specify manual sections to search]: :->sects' + # @todo Could enumerate these + '(-T -t --troff --troff-device)'{-T-,--troff-device=-}'[specify roff output device]::roff output device' + '(-u --update)'{-u,--update}'[update database caches]' + '(: -)--usage[display brief usage information]' + '(: -)'{-V,--version}'[display version information]' + "(${(j< >)modes})"{-W,--where-cat}'[display cat file locations]' + '--warnings=[enable specified groff warnings]:groff warnings' + '(-a --all --regex)--wildcard[treat page name as shell glob]' + # @todo Could enumerate these + '(-X --gxditview)'{-X-,--gxditview=-}'[display output in gxditview using specified DPI]::resolution (DPI) [75]' + # @todo Post-process how? + '(-t --troff -Z --ditroff)'{-Z,--ditroff}'[post-process output for chosen device]' + ) + [[ $variant == darwin* ]] && args+=( + # We use _files here because browsers are usually in /Applications, which + # typically isn't in PATH + '-B+[specify browser to use for HTML files]:Web browser:_files' + '-c[reformat source man page]' + # @todo -d should be exclusive with this above + '(-d)-D[display man page along with debugging information]' + '(-D -F --preformat)'{-F,--preformat}'[format man page only (do not display)]' + '-H+[specify command to render HTML as text]:HTML pager:_path_commands' + # --help and --version are undocumented but functional + '(: -)--help[display help information]' + # -s is also undocumented; it's provided for compatibility with Solaris + '!(-S)-s+: :->sects' + '(: -)'{-v,--version}'[display version information]' + "(${(j< >)modes})-W[display file locations, one per line, with no other information]" + ) + [[ $variant == netbsd* ]] && args+=( + '-h[display only synopsis lines]' + '(: -)-p[display manual search path]' + '-S+[display only man pages with file names matching specified string]:search string' + ) + [[ $variant == openbsd* ]] && args+=( + "(${(j< >)modes})-l+[format and display specified file]:*:::manual file:_files" + # @todo Could enumerate these + '-S[search manual of specified architecture]:architecture' + ) + [[ $variant == solaris* ]] && args+=( + "(${(j< >)modes})-l[display file locations]" + '-r[format man page only (do not display)]' + '(-a)-s+[specify manual sections to search]: :->sects' + # @todo Does this in fact want a file path? + '-T+[format man page using specified macro package]:macro package:_files' + ) + [[ $variant == aix* ]] && args+=( + '-c[display man page using cat]' + '-F[display only first matching entry]' + '-m[only search paths specified by -M/MANPATH]' + '-r[search remotely]' + ) + + # Strip (most) long options from non-Linux platforms + if [[ $variant == darwin* ]]; then + args=( ${(M)args:#((#s)|*\))(\*|)(-[^-]|--(help|path|pref|vers))*} ) + elif [[ $variant != linux* ]]; then + args=( ${(M)args:#((#s)|*\))(\*|)-[^-]*} ) + fi fi + _arguments -s -S : $args '*::: :->man' && return 0 + [[ -n $state ]] || return 1 + if (( ! $#_manpath )); then local mp mp=( ${(s.:.)$(manpath 2>/dev/null)} ) @@ -25,12 +183,14 @@ _man() { (( $#_manpath )) || _manpath=( /usr/man(-/) /(opt|usr)/(pkg|dt|share|X11R6|local)/(cat|)man(-/) ) - integer index=$words[(I)-M] - if (( index )); then - local opt - opt=$words[index+1] - _manpath=($opt) - fi + # Override man path + [[ -n ${opt_args[-M]} ]] && + _manpath=( ${(s<:>)opt_args[-M]} ) + + # Augment man path + [[ $variant == (netbsd|openbsd)* ]] && + [[ -n ${opt_args[-m]} ]] && + _manpath+=( ${(s<:>)opt_args[-m]} ) # `sman' is the SGML manual directory for Solaris 7. # 1M is system administrator commands on SVR4 @@ -44,52 +204,190 @@ _man() { # $sect_dirname is from the filesystem, the "3" in "/usr/share/man/man3" # These are used by _man_pages local sect sect_dirname - if [[ $OSTYPE = solaris* ]]; then - sect=${${words[(R)-s*]#-s}:-$words[$words[(i)-s]+1]} - sect="${sect//,/|}" - elif [[ -n ${sect:=$words[$words[(i)-S]+1]} || -n ${sect:=$MANSECT} ]]; then - sect="${sect//:/|}" - sect="${sect//,/|}" - elif (( CURRENT > 2 )); then - case $words[2] in - (-a) sect='*';; - (-*) ;; - (*) sect=$words[2];; - esac + + # Take care: We can't use the sections from these options until we've finished + # completing them; otherwise (e.g.) -s1:<TAB> will give no results + if + [[ $service != man ]] || [[ $state == sects ]] || (( $+opt_args[-a] )) + then + sect='*' + elif + [[ $variant == (darwin|linux)* ]] && + [[ -n ${opt_args[(i)-S|-s|--sections]} ]] + then + noinsert=1 + sect=${opt_args[${opt_args[(i)-S|-s|--sections]}]//[:,]/|} + elif + [[ $variant == (netbsd|openbsd|solaris)* ]] && (( $+opt_args[-s] )) + then + noinsert=1 + sect=${opt_args[-s]//,/|} + elif [[ $variant == (dragonfly|freebsd)* ]] && (( $+opt_args[-S] )); then + noinsert=1 + sect=${opt_args[-S]//:/|} + # It's only a small help, but, per man-db, we can avoid treating an initial + # operand like `8139too` as a section name by ensuring that only the first + # character is a digit. This doesn't do much for stuff like `2to3`, but we can + # at least special-case a few common patterns for now + elif + (( CURRENT > 1 )) && + [[ $variant != solaris* ]] && + [[ ${${(Q)words[1]}##(2to3|7z)*} == ([0-9](|[^0-9[:punct:]]*)|[lnopx]) ]] + then + noinsert=1 + sect=$words[1] + elif [[ -n ${sect:=$MANSECT} ]]; then + sect=${sect//:/|} fi - if [[ $sect = (<->*|1M|l|n) || $sect = *\|* ]]; then + # Colons may have been escaped + sect=${(Q)sect} + + if [[ $sect = (<->*|[lnopx]) || $sect = *\|* ]]; then + sects=( ${(s.|.)sect} ) + + # Most man implementations support partial matching of a page's + # (sub-)section name — e.g., `3per` for `3perl`. The (sub-)section name may + # or may not correspond to the directory name (most systems combine + # sub-sections), but we'll assume that if it starts with a number and we're + # not on Solaris (which doesn't support this feature at all) that we can do + # a match against the leading number. This is irritating if you DO want the + # exact sub-section specified, but unfortunately there's no way to determine + # this programmatically — i guess we could add a style to control it () { - local -a sects=( ${(s.|.)sect} ) - if [[ $sect != (l|n) ]]; then - sects=( ${sects%%[^0-9]#} ) - fi - dirs=( $^_manpath/(sman|man|cat)${^sects}*/ ) - } - if [[ $sect == *\|* ]]; then sect="($sect)"; fi + for 1; do + if [[ $OSTYPE == solaris* || $1 != <->* ]]; then + dirs+=( $^_manpath/(sman|man|cat)$1(|.*)/ ) + else + dirs+=( $^_manpath/(sman|man|cat)${1%%[^0-9]#}*/ ) + fi + done + } $sects + + sect=${(j<|>)sects} + [[ $sect == *'|'* ]] && sect="($sect)" awk="\$2 == \"$sect\" {print \$1}" else + sect= dirs=( $^_manpath/(sman|man|cat)*/ ) awk='{print $1}' fi + + # Ignore directories with no pages inside + dirs=( ${^dirs}(#qFN) ) + # Solaris 11 and on have a man-index directory that doesn't contain manpages dirs=( ${dirs:#*/man-index/} ) - if [[ $OSTYPE = solaris* && ( $words[CURRENT] = -s* || $words[CURRENT-1] == -s ) ]]; then - [[ $words[CURRENT] = -s* ]] && compset -P '-s' - sects=( ${(o)${dirs##*(man|cat)}%/} ) - _wanted sections expl 'section' compadd -a sects - elif zstyle -t ":completion:${curcontext}:manuals" separate-sections; then - typeset -U sects - local ret=1 + sects=( ${(o)${${dirs##*(man|cat)}%.*}%/} ) - sects=( ${(o)${dirs##*(man|cat)}%/} ) + # If we've got this far, we can build our look-up table for descriptions of + # the more common sections. Unless otherwise labelled, the more specific ones + # come from Solaris or one of its variants + (( $#sects )) && () { + sect_descs=( + 0 'library headers' + 1 'general commands' + 1cups 'CUPS commands' + 1m 'maintenance commands' + 1openssl 'OpenSSL commands' + 2 'system calls' + 3 'library functions' + 3c 'C library functions' + 3curses 'curses library functions' + 3elf 'ELF library functions' + 3f 'Fortran library functions' + 3lua 'Lua features' # NetBSD + 3mail 'mailbox library functions' + 3openssl 'OpenSSL library functions' + 3pam 'PAM library functions' + 3pool 'pool configuration library functions' + 3proc 'process control library functions' + 3x11 'Xlib functions' + 3xcurses 'curses library functions [X/Open]' + 4 'devices and drivers' + 5 'file formats and conventions' + 3openssl 'OpenSSL configuration files' + 6 'games' + 7 'miscellanea' + 8 'maintenance commands and procedures' + 9 'kernel features' + 9lua 'Lua kernel bindings' # NetBSD + l 'local documentation' # AIX, etc. — TCL on some systems? + n 'new documentation' # AIX, etc. + o 'old documentation' # AIX, etc. + p 'public documentation' # AIX, etc. + x 'X11 features' + ) + + # Add POSIX variants + for 1 in ${(k)sect_descs}; do + [[ $1 == <-> ]] || continue + sect_descs+=( "${1}p" "${sect_descs[$1]} [POSIX]" ) + done + + # Add OS-specific stuff that's too risky for or overrides the general list + [[ $OSTYPE == darwin* ]] && sect_descs+=( n 'Tcl/Tk features' ) + [[ $OSTYPE == openbsd* ]] && sect_descs+=( 3p 'Perl features' ) + # @todo Oracle Solaris 11.4 adopts the BSD/Linux structure, making many of + # these inaccurate — this should be handled accordingly in the future. If + # OSTYPE isn't helpful (since other Solaris descendants may not follow + # suit), we could perhaps use the presence of SysV-style sections under + # _manpath as the determinant + [[ $OSTYPE == solaris* ]] && sect_descs+=( + 1t 'Tcl/Tk features' + 3m 'mathematical library functions' + 4 'file formats and conventions' + 5 'miscellanea' + 7 'special files' + 7d 'devices' + 7fs 'file systems' + 7i 'ioctl requests' + 7m 'STREAMS modules' + 7p 'protocols' + 9e 'driver entry points' + 9f 'driver functions' + 9p 'driver properties' + 9s 'driver data structures' + ) + } + + [[ $state == sects ]] && { + local s + local -a specs + + (( $#sects )) || { + _message -e sections 'manual section' + return 1 + } + + # Build specs from descriptions + for s in $sects; do + specs+=( "${s}:${(b)sect_descs[$s]}" ) + done + specs=( ${specs%:} ) + + if [[ $variant == (darwin|dragonfly|freebsd|linux)* ]]; then + _sequence -s : _describe -t sections 'manual section' specs + elif [[ $variant == solaris* ]]; then + _sequence -s , _describe -t sections 'manual section' specs + else + _describe -t sections 'manual section' specs + fi + return + } + + if zstyle -t ":completion:${curcontext}:manuals" separate-sections; then + local d ret=1 (( $#sects )) || return 1 _tags manuals.${^sects} while _tags; do for sect_dirname in $sects; do - _requested manuals.$sect_dirname expl "manual page, section $sect_dirname" _man_pages && + d=$sect_dirname + (( $+sect_descs[$d] )) && d+=" (${sect_descs[$d]})" + + _requested manuals.$sect_dirname expl "manual page, section $d" _man_pages && ret=0 done (( ret )) || return 0 @@ -113,14 +411,14 @@ _man_pages() { local pages sopt # What files corresponding to manual pages can end in. - local suf='.((?|<->*)(|.gz|.bz2|.Z|.lzma))' + local suf='.((?|<->*|ntcl)(|.gz|.bz2|.z|.Z|.lzma))' if [[ $PREFIX$SUFFIX = */* ]]; then # Easy way to test for versions of man that allow file names. # This can't be a normal man page reference. # Try to complete by glob first. if [[ -n $sect_dirname ]]; then - _path_files -g "*.*$sect_dirname*(|.gz|.bz2|.Z|.lzma)" "$expl[@]" + _path_files -g "*.*$sect_dirname*(|.gz|.bz2|.z|.Z|.lzma)" "$expl[@]" else _path_files -g "*$suf" "$expl[@]" && return _path_files "$expl[@]" @@ -129,7 +427,7 @@ _man_pages() { fi pages=( ${(M)dirs:#*$sect_dirname/} ) - pages=( ${^pages}/"*$sect${sect:+"*"}" ); + pages=( ${^pages}/"*${sect:+.$sect"*"}" ) pages=( ${^~pages}(N:t) ) (($#mrd)) && pages[$#pages+1]=($(awk $awk $mrd)) @@ -138,8 +436,8 @@ _man_pages() { # beginning with .<->: that handles problem cases like files called # `POSIX.1.5'. - [[ $OSTYPE = solaris* ]] && sopt='-s ' - if ((CURRENT > 2)) || + [[ $variant = solaris* ]] && sopt='-s ' + if ((CURRENT > 1 || noinsert)) || ! zstyle -t ":completion:${curcontext}:manuals.$sect_dirname" insert-sections then compadd "$@" - ${pages%$~suf} diff --git a/Completion/Unix/Command/_md5sum b/Completion/Unix/Command/_md5sum index 073e6beba..8e93fbbac 100644 --- a/Completion/Unix/Command/_md5sum +++ b/Completion/Unix/Command/_md5sum @@ -1,15 +1,48 @@ -#compdef md5sum gmd5sum - -_arguments -S \ - '(-b --binary)'{-b,--binary}'[read in binary mode]' \ - '(-c --check)'{-c,--check}'[read MD5 sums from the FILEs and check them]' \ - '--tag[create a BSD-style checksum]' \ - '(-t --text)'{-t,--text}'[read in text mode]' \ - "--ignore-missing[don't fail or report status for missing files]" \ - '(-q --quiet)'{-q,--quiet}"[don't print OK for each successfully verified file]" \ - '--status[no output, status code shows success]' \ - '--strict[exit non-zero for improperly formatted checksum lines]' \ - '(-w --warn)'{-w,--warn}'[warn about improperly formatted checksum lines]' \ - '(-)--help[display help and exit]' \ - '(-)--version[output version information and exit]' \ - '*:files:_files' +#compdef md5sum gmd5sum b2sum gb2sum sha1sum gsha1sum sha224sum gsha224sum sha256sum gsha256sum sha384sum gsha384sum sha512sum gsha512sum + +# This function covers the various digest utilities (which are all essentially +# the same program) from GNU Coreutils. It does NOT cover GNU `cksum` and `sum`, +# nor the various BSD digest utilities like `md5` and `sha1` — see `_cksum` for +# all of those. See `_shasum` for the `shasum` Perl script. +# +# @todo Support BusyBox? + +local type +local -a args + +case $service in + *md5*) type=MD5 ;; + *b2*) type=BLAKE2 ;; + *sha*) type=SHA${service//[^0-9]/} ;; +esac + +# General options +args+=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' +) +# Summing options +args+=( + + sum + '(chk)--tag[create BSD-style checksums]' + '(chk -b -t --binary --text)'{-b,--binary}'[read in binary mode]' + '(chk -b -t --binary --text)'{-t,--text}'[read in text mode]' +) +# This is the only option that differs amongst all of these tools +[[ $service == *b2* ]] && args+=( + '(chk -l --length)'{-l+,--length=}'[specify digest length]:digest length (bits, multiples of 8)' +) +# Verification options +args+=( + + chk + '(sum -c --check)'{-c,--check}"[verify $type checksums from input files]" + "(sum)--ignore-missing[don't fail or report status for missing files]" + "(sum)--quiet[don't print OK for each verified file]" + '(sum -w --warn)--status[suppress all output]' + '(sum)--strict[exit non-zero for improperly formatted checksum lines]' + '(sum -w --status --warn)'{-w,--warn}'[warn about each improperly formatted checksum line]' +) +# Operands +args+=( '*: :_files' ) + +_arguments -s -S : $args diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc index 45d93550d..4f200c69e 100644 --- a/Completion/Unix/Command/_mpc +++ b/Completion/Unix/Command/_mpc @@ -37,6 +37,7 @@ _mpc_command() { disable:"disable an output" enable:"enable an output" toggleoutput:"toggle an output" + outputset:"set output attributes" idle:"wait until an event occurs" idleloop:"loop waiting for events" insert:"insert a song after the currently playing song in the playlist" @@ -73,6 +74,7 @@ _mpc_command() { stop:"stop the currently playing playlists" toggle:"toggles Play/Pause, plays if stopped" update:"scan music directory for updates" + rescan:"rescan music directory (including unchanged files)" version:"report version of MPD" volume:"set volume" status:"display MPD status" @@ -222,6 +224,16 @@ _mpc_toggleoutput() { _mpc_helper_outputs } +_mpc_outputset() { + if (( CURRENT == 2 )); then + _mpc_helper_outputs + else + _values -w -S = attribute \ + 'dop:setting:(1 0)' \ + 'allowed_formats:formats' + fi +} + _mpc_move() { if (( $#words <= 3 )); then _mpc_helper_songnumbers @@ -318,6 +330,10 @@ _mpc_update() { _mpc_helper_files } +_mpc_rescan() { + _mpc_helper_files +} + if [[ $service = *MPD_HOST* ]]; then _hosts return @@ -339,7 +355,7 @@ if [[ $state = formats ]]; then compset -P '([^%]|%[^%]#%)#' _wanted metadata expl 'metadata delimiter' compadd -p % -S % \ artist album albumartist comment composer date disc genre performer title \ - track time file position mtime mdate && ret=0 + track time file position id prio mtime mdate && ret=0 fi return ret diff --git a/Completion/Unix/Command/_netstat b/Completion/Unix/Command/_netstat new file mode 100644 index 000000000..c03aae9a2 --- /dev/null +++ b/Completion/Unix/Command/_netstat @@ -0,0 +1,337 @@ +#compdef netstat + +local Wopt Xopt nopt="[don't resolve addresses to names]" +local lopt='[show only listening sockets]' +local zopt='-z[reset statistic counters after displaying them]' +local popt='(-f)-p+[filter by protocol]:protocol:compadd -a plist' +local Iopt='(-i)-I+[show information about the specified interface]:interface:_net_interfaces' +local set sel +local -A sets +local -a Mopts families flist plist args sockets extend interval verbose +local -a {sel_,}{bpf,dhcp,groups,interfaces,masquerade,media,memory,multicast,pcb,queues,routing,statistics,wireless} + +case $OSTYPE in + linux-gnu) + families=( + '(-4 --inet)'{-4,--inet} + '(-6 --inet)'{-4,--inet6} + '(-A --protocol)'{-A+,--protocol=}':protocol:_sequence compadd - inet inet6 unix ipx ax25 netrom ddp bluetooth' + --unix -x --ip --tcpip --ax25 --x25 --rose --ash + --bluetooth --ipx --netrom --ddp --appletalk --econet --ec + ) + extend=( \*{-e,--extend}'[show additional information]' ) + verbose=( '(-v --verbose)'{-v,--verbose}'[show what is going on]' ) + args=( + '(-c --continuous)'{-c,--continuous}'[repeat information every second]' + '!(-n --numeric)'{-N,--symbolic} + '(-n --numeric)'{-n,--numeric}"$nopt" + --numeric-hosts --numeric-ports --numeric-users + '1: :_guard "[0-9]#" "repeat interval (seconds)"' + - '(help)' + '(- 1)'{-h,--help}'[display usage information]' + '(- 1)'{-V,--version}'[display version information]' + ) + sets=( + routing '(--route|-[^-]#r*)' + groups '(--groups|-[^-]#g*)' + interfaces '(--interfaces|-[^-]#[iI]*)' + statistics '(--statistics|-[^-]#s*)' + masquerade '(--masquerade|-[^-]#M*)' + ) + + sel_routing=( '(-r --route)'{-r,--route}'[display routing table]' ) + sel_interfaces=( + '(-I --interfaces)-i[display interface table]' + '(-i -I --interfaces)'{--interface=-,-I=-}'[display interface table]::interface:_net_interfaces' + ) + sel_groups=( '(-g --groups)'{-g,--groups}'[display multicast group memberships]' ) + sel_masquerade=( '(-M --masquerade)'{-M,--masquerade}'[display masqueraded connections]' ) + [[ -e /proc/net/ip_masquerade ]] || sel_masquerade=( \!${^sel_masquerade} ) + sel_statistics=( '(-s --statistics -c --continuous -n --numeric --numeric-hosts --numeric-ports --numeric-users)'{-s,--statistics}'[display networking statistics]' ) + + sockets=( + $families $verbose + --tcp -t --udp -u --udplite -U --sctp -S --raw -w + '(-2 --l2cap)'{-2,--l2cap} + '(-f --rfcomm)'{-f,--rfcomm} + '(-a --all -l --listening)'{-l,--listening}$lopt + '(-a --all -l --listening)'{-a,--all}'[show all sockets]' + --symbolic -N --extend -e + '(--timers -o)'{--timers,-o}'[show information on networking timers]' + '(--program -p)'{--program,-p}'[show process id and program name for sockets]' + '(--wide -W)'{--wide,-W}"[don't truncate IP addresses in output]" + '(-Z --context)'{-Z,--context}'[display SELinux security context for sockets]' + ) + routing=( + $families $extend $verbose + '-C[display routing cache instead of FIB]' + ) + interfaces=( + $extend $verbose + '(-a --all)'{-a,--all}'[show interfaces that are not up]' + ) + groups=() + masquerade=( $extend ) + statistics=( $families ) + ;; + solaris*|darwin*|dragonfly*|freebsd*) + families=( '(-p -4 -6)-f+[specify address family]:address family:compadd -a flist' ) + ;| + freebsd*) + families+=( + '(-6 -f)-4[show IPv4 only]' + '(-4 -f)-6[show IPv6 only]' + ) + ;| + (open|net)bsd*) + popt='(-f)-p+[filter by protocol]:protocol:compadd - ${(M)${(f)"$(</etc/protocols)"}##[a-z0-9]#}' + families=( + '(-u)-f+[specify address family]:address family:_sequence compadd - -a flist' + '(-f)-u[limit reports to the unix address family]' # undocumented on NetBSD + ) + ;| + *) # everything except linux + sets=( + routing '-[^-]#r*' + groups '-[^-]#g*' + interfaces '-[^-]#[iIw]*' + memory '-[^-]#m*' + statistics '-[^-]#s*' + ) + flist=( inet inet6 unix ) + verbose=( '-v[verbose]' ) + sel_routing=( '-r[display routing table]' ) + sel_groups=( '-g[display multicast group memberships]' ) + sel_interfaces=( $Iopt '-i[display interface table]' ) + sel_statistics=( '*-s[display per protocol statistics]' ) + sockets=( $families -n$nopt '-a[show all sockets]' ) + routing=( -n$nopt ) + interfaces=( $families -n$nopt ) + statistics=( $families ) + ;| + (open|net)bsd*) + sets+=( pcb '-[^-]#P*' ) + sel_pcb=( '-P+[display contents of the protocol control block]:pcb' ) + routing+=( $verbose '(-L)-s[show routing statistics]' ) + groups+=( $families + '(-s)-l[display wider fields for the IPv6 multicast routing table]' + '(-l)-s[show multicast routing statistics]' + ) + interfaces+=( + '(-p)-s[show interface statistics]' + ) + ;| + darwin*|dragonfly*|(net|free|open)bsd*) + sockets+=( '-A[show address of a PCB associated with sockets]' ) + interfaces+=( + '-b[show the number of bytes in and out]' + '-d[show the number of dropped packets]' + '1: :_guard "[0-9]#" "repeat interval (seconds)"' + ) + routing=( $families ) + sel_memory=( '-m[display statistics recorded by the memory management routines]' ) + sel_interfaces+=( '(1 -a -f -i -p -s)-w+[display packet traffic at intervals]:interval (seconds)' ) + ;| + darwin*|dragonfly*|(net|free)bsd*) + interfaces+=( '-a[show multicast addresses currently in use]' ) + ;| + dragonfly*|(net|free|open)bsd*) + Mopts=( + '-M+[extract values from specified core]:core file:_files' + '-N+[extract name list from specified system image]:system image:_files' + ) + interfaces+=( + '-h[print all counters in human readable form]' + ) + sockets+=( $Mopts ) + ;| + darwin*|dragonfly*|freebsd*) + Wopt='-W+[avoid truncating fields even if it causes overflow]' + sockets+=( $Wopt + '-L[show size of listen queues]' + ) + groups+=( $Wopt ) + ;| + dragonfly*|netbsd*|freebsd*) + sockets+=( '(-n)-S[show network addresses as numbers but show ports symbolically]' ) + ;| + netbsd*|freebsd*) + sets+=( bpf '-[^-]#B*' ) + sel_bpf=( '-B[display statistics about bpf(4) peers]' ) + ;| + dragonfly*|freebsd*) + plist=( divert icmp igmp ip ipsec pim tcp udp icmp6 ip6 rip6 tcp udp pfkey ctrl data ) + sockets+=( $popt ) + statistics+=( $popt $zopt $Mopts ) + memory+=( $Mopts ) + routing+=( $Mopts $zopt + '(-A -a -f -l -n -W)*-s[show routing statistics]' + '-W[show path MTU for each route]' + ) + groups+=( $families $Mopts + '(-W)*-s[show multicast routing statistics; repeat to suppress those with zero counters]' + ) + ;| + + solaris2.<11->) + args=( '-T+[specify time format]:time format:((u\:seconds\ since\ epoch d\:standard\ date\ format))' ) + sockets=( '-u[list user, pid and program that created network endpoint]' ) + ;& + solaris*) + args=( -A '-*' $args ) + interval=( + '1: :_guard "[0-9]#" "repeat interval (seconds)"' + '2: :_guard "[0-9]#" "count"' + ) + sets+=( + dhcp '-[^-]#D*' + media '-[^-]#p*' + multicast '-[^-]#M*' + ) + sel_media=( '-p[display net to media tables]' ) + sel_memory=( '-m[display STREAMS memory statistics]' ) + sel_multicast=( '-M[display multicast routing tables]' ) + sel_dhcp=( '-D[display status of DHCP configured interfaces]' ) + sockets+=( + $verbose + '-R[show extended security attributes]' + '-P[specify protocol]:protocol:(ip ipv6 icmp icmpv6 igmp udp tcp rawip)' + ) + routing+=( $verbose + '*-f+[filter routing table]:rule:_values -S \: "filter rule" $flist + "af[specify address family]\:family\:(inet inet6 unix)" + "outif[specify output interface]\:interface\:_net_interfaces" + "dst[specify destination IP]\:IP address" + "flags[select routes tagged with flags]\:flags"' \ + '-a[show state of all routing tables]' + '-R[show extended security attributes]' + ) + groups+=( $families -n$nopt $verbose ) + interfaces+=( $interval + '-a[show state of all interfaces]' + ) + statistics+=( + '-P[specify protocol]:protocol:(ip ipv6 icmp icmpv6 igmp udp tcp rawip)' + ) + media=( -n$nopt $families ) + memory+=( $verbose $interval ) + multicast+=( + -n$nopt $families + '-s[show per protocol statistics]' + ) + dhcp=( $families $Iopt ) + ;; + darwin*) + sets+=( queues '-[^-]#q*' ) + sel_queues=( '*-q[display network interface send queue statistics]' ) + sel_memory=( \*$sel_memory ) + sockets+=( + '-l[show full IPv6 address]' + '-W[avoid truncating addresses]' + ) + routing+=( '-l[show mtu and use wider display]' ) + interfaces+=( + '(-x)-R[show reachability information]' + '-S[show interface link status and state]' + '(-R)-x[show extended reachability information]' + ) + queues=( $Iopt + '-c+[limit statistics to specified queue]:queue' + ) + groups+=( $families + '*-v[show link-layer memberships; repeat for timers and counters]' + ) + ;; + dragonfly*) + plist+=( carp ) + sockets+=( + '-P[show additional protocol-specific information]' + '-c+[access cpu specific route table]:cpu' + ) + interfaces+=( $zopt + '-B[show maximum buffer sizes instead of current buffer usage]' + '-t[show the contents of watchdog timers]' + '(-a -B -b -d -h -n -t -w)*-s[show protocol statistics; repeat to suppress those with zero counters]' + ) + routing+=( + '-A[show contents of internal Patricia tree structures]' + '-a[show protocol-cloned routes]' + ) + ;; + openbsd*) + sets+=( wireless '-W*' ) + sel_wireless=( '-W+[display per-interface IEEE 802.11 wireless statistics]:interface' ) + flist+=( local mpls ) + sockets+=( -l$lopt '-B[show buffer sizes for TCP sockets]' ) + routing+=( + '-F[only show routes with gateway in the same address family as the destination]' + '-T+[select an alternate routing table to query]:routing table' + ) + interfaces+=( + '-c+[show specified number of updates, then exit]:count' + '-q[only show interfaces that have seen packets]' + '-t[show current value of the watchdog timer function]' + ) + statistics+=( $popt ) + pcb+=( $Mopts $verbose ) + ;; + netbsd*) + popt='(-f)-p+[filter by protocol]:protocol:compadd - ${(M)${(f)"$(</etc/protocols)"}##[a-z0-9]#}' + Xopt='-X[force use of sysctl(3) when retrieving information]' + flist+=( arp ns atalk mpls local ) + sets+=( queues '-[^-]#q*' ) + sel_queues=( '-q[display software interrupt queue details for all protocols]' ) + routing+=( $Xopt + "(-s)-L[don't show link-level routes]" + '-T[show MPLS tags for the routing tables]' + ) + bpf+=( $Xopt $Iopt + '-s[show bpf(4) statistics]' + ) + interfaces+=( $Xopt ) + memory+=( $Xopt) statistics+=( $Xopt ) + pcb+=( $Mopts $popt ) + ;; + freebsd<11->.*) + routing+=( '-F+[show specified routing table]:routing table' ) + bpf=( '-z[reset statistic counters after displaying them]' ) + statistics+=( $bpf[-1] ) + ;& + freebsd*) + flist+=( pfkey netgraph ng link ) + plist+=( sctp ipsec6 pfkey ) + + sets+=( netisr '-[^-]#Q*' ) + sel_netisr=( '-Q[display netisr(9) statistics]' ) + sockets+=( + '-R[show flowid and flowtype for each socket]' + '-T[show diagnostic information from the TCP control block]' + '-x[show socket buffer and TCP timer statistics]' + ) + interfaces+=( + $popt $Mopts $Iopt $Wopt + '-q+[exit after specified number of outputs]:number' + ) + bpf+=( $Iopt $zopt ) + ;; +esac + +# Ignore display specific options except the default (socket) display until a +# display has been selected. This is not strictly correct (options can be in +# any order) but makes the completion much more useful. Descriptions for +# options that select a specific display (option set) typically start with +# "display" to set them apart from other options. +sock='' +for set in ${(k)sets}; do + sel=sel_$set + if [[ -z $words[(r)$~sets[$set]] ]]; then + ign='!' + else + sock='!' + ign='' + fi + args+=( - "$set" ${(P)sel} ${ign}${(P)^set} ) +done +args+=( - sockets ${sock}${sockets} ) + +_arguments -s -S $args diff --git a/Completion/Unix/Command/_nginx b/Completion/Unix/Command/_nginx new file mode 100644 index 000000000..7d785c822 --- /dev/null +++ b/Completion/Unix/Command/_nginx @@ -0,0 +1,20 @@ +#compdef nginx + +local -ah signals=( + 'quit\:shut down gracefully (SIGQUIT)' + 'reload\:reload configuration (SIGHUP)' + 'reopen\:re-open log files (SIGUSR1)' + 'stop\:shut down quickly (SIGTERM)' +) + +_arguments -s -S : \ + '(: * -)'{-\?,-h}'[display help information]' \ + '(: * -)-v[display version information]' \ + '(: * -)-V[display version information and configure options]' \ + '-c+[specify configuration file]:configuration file:_files' \ + '-g+[specify global configuration directives]:configuration directives' \ + '-p+[specify prefix path]:prefix path:_directories' \ + '(-s)-q[suppress non-error messages (with -t/-T)]' \ + "(-q -t -T)-s+[send specified signal to master process]:signal:((${(j< >)${(@q-)signals}}))" \ + '(-s -T)-t[test configuration]' \ + '(-s -t)-T[test and dump configuration]' diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep index ec3f8bfd0..3b4d082a7 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -1,185 +1,177 @@ #compdef pgrep pkill -local curcontext="$curcontext" state line ret=1 expl +# Notes: +# - We assume that Linux systems use procps-ng - specifically, procps-ng >=3.3.4 +# (which changed the behaviour of -f and added -a) +# - We don't really need to keep pgopts and pkopts separate, but it seems like +# it should make things a bit easier to follow +# - @todo We could complete log-in classes given to -c +# - @todo We could complete routing tables given to -T + +local curcontext="$curcontext" state line ret=1 expl pgopts pkopts no typeset -A opt_args -typeset -a arguments - -arguments=('-P[parent process id]:parent process id:->ppid' - '-F[match only in process in pidfile]:files:_files' - '-g[match only in process group ids]:group:->pgid' - '-G[match only real group id]:group:_groups' - '-j[match only in processes inside jails]:jail id:_sequence _jails -0 -o jid' - '-J[match only in project ids]:project id:->projid' - '-M[extract the name list from the specified core]:files:_files' - '-N[extract the name list from the specified system]:files:_files' - '-s[match only session id]:session id:->sid' - '-t[match only controlled by terminal]:terminal device:_sequence _ttys -d' - '-T[match only in processes specified routing table in rtable]' - '-u[match only effective user id]:user:_users' - '-U[match only real user id]:user:_users' - '(-n)-o[oldest process]' - '(-o)-n[newest process]' - '-a[include process ancestors in the match list]' - '-c[print a count of matching processes]' - '-f[match against full command line]' - '-i[ignore case distinctions]' - '-I[confirmation before attempting to single each process]' - '-L[given pidfile must be locked]' - '-q[do not write anything to standard output]' - '-S[search also in system processes]' - '-v[negate matching]' - '-w[show thread ids instead of pids]' - '-x[match exactly]' - '-z[match only in zones]:zone:_zones') - -if [[ $service == 'pgrep' ]]; then - arguments+=('-d[output delimiter]:delimiter:compadd ${(s\:\:)IFS}' - '-l[list name in addition to id]') -fi - -local optchars -case "$OSTYPE" in +typeset -a arguments sig_arguments aopts + +# These arguments (a) are common to all variants (like -x), (b) are the most +# common amongst all variants (like -a), or (c) have a single unambiguous +# meaning amongst all variants (like --help). Many of them are filtered out or +# overridden below +arguments=( + '-a[include process ancestors in match list]' + '-c+[match only on specified login class]:login class' + '(-F --pidfile)'{-F+,--pidfile=}'[match only processes in specified PID file]:PID file:_files' + '(-f --full)'{-f,--full}'[match against full command line]' + '(-G --group)'{-G+,--group=}'[match only on specified real group IDs]: :_sequence _groups' + '(-g --pgroup)'{-g+,--pgroup=}'[match only on specified process group IDs]: :->pgid' + '(: * -)'{-h,--help}'[display help information]' + '-I[request confirmation before signalling each process]' + '-i[ignore case distinctions]' + '-j+[match only on specified jail IDs]:jail:_sequence _jails -0 -o jid' + '(-L --logpidfile)'{-L,--logpidfile}'[fail if PID file not locked (with -F)]' + '(-N)-M+[extract name list from specified core]:core file:_files' + '(-M)-N+[extract name list from specified system]:system file:_files' + '(-o -n --oldest --newest)'{-n,--newest}'[match newest process]' + '(-o -n --oldest --newest)'{-o,--oldest}'[match oldest process]' + '(-P --parent)'{-P+,--parent=}'[match only on specified parent process IDs]: :->ppid' + '(-l)-q[suppress normal output]' + '-S[search also in system processes (kernel threads)]' + '(-s --session)'{-s+,--session=}'[match only on specified process session IDs]: :->sid' + # _signals is OK here - we do it differently below + '(ss)--signal=[specify signal to send to process]: :_signals -s' + '-T+[match only on specified routing table]:routing table' + '(-t --terminal)'{-t+,--terminal=}'[match only on specified controlling terminals]: :_sequence _ttys -do' + '(-U --uid)'{-U+,--uid=}'[match only on specified real user IDs]: :_sequence _users' + '(-u --euid)'{-u+,--euid=}'[match only on specified effective user IDs]: :_sequence _users' + '(-v --inverse)'{-v,--inverse}'[negate matching]' + '(-x --exact)'{-x,--exact}'[match process name or command line (with -f) exactly]' + '--ns=[match only on same namespaces as specified PID]: :_pids' + '--nslist=[match only on specified namespaces (with --ns)]:namespace:(ipc mnt net pid user uts)' + '(: * -)'{-V,--version}'[display version information]' + '-z+[match only on specified zone IDs]:zone:_sequence _zones' +) +[[ $service == pgrep ]] && arguments+=( + '(-d --delimiter)'{-d+,--delimiter=}'[specify output delimiter]:delimiter:compadd ${(s<>)IFS}' + '(-q)-l[display process name (and arguments with -f)]' + '(-w --lightweight)'{-w,--lightweight}'[show all thread IDs instead of PID]' +) +[[ $service == pkill ]] && arguments+=( + '(-e --echo)'{-e,--echo}'[display signalled process]' + '-l[display kill command]' +) + +case $OSTYPE in linux*) - optchars="cflvxdnoPgsuUGtw" + # Note: We deliberately exclude -v but not --inverse from pkill + pgopts=acdFfGghLlnoPstUuVvwx- + pkopts=ceFfGghLnoPstUuVx- + arguments=( + ${arguments:#((#s)|*\))(\*|)-[acl]*} + '(-c --count)'{-c,--count}'[display count of matching processes]' + ) + [[ $service == pgrep ]] && arguments+=( + '(-a -l --list-full --list-name)'{-a,--list-full}'[display full command line]' + '(-a -l --list-full --list-name)'{-l,--list-name}'[display process name]' + ) ;; - freebsd*) - optchars="LSafilnoqvxFGMNPUdgjstu" + dragonfly*|freebsd*) + pgopts=acdFfGgijLlMNnoPqSstUuvx + pkopts=acFfGgIijLlMNnoPstUuvx ;; openbsd*) - optchars="flnoqvxdGgPsTtUu" + pgopts=dfGglnoPqsTtUuvx + pkopts=fGgIlnoPqsTtUuvx ;; darwin*) - optchars="LafilnoqvxFGPUdgtu" + pgopts=adFfGgiLlnoPqtUuvx + pkopts=aFfGgIiLlnoPtUuvx ;; solaris*) - optchars="flvxdnoPgsuUGJtTcz" - arguments=( ${arguments##-T*} ) - arguments=( ${arguments##-c*} ) - arguments+=( '-T[match only processes in task ids]:taskid:->task' ) - arguments+=( '-c[match only processes in contract ids]:taskid:->contract' ) + pgopts=cdfGglnoPsTtUuvxz + pkopts=cfGgnoPsTtUuvxz + arguments=( + ${arguments:#((#s)|*\))(\*|)-[cT]*} + '-c+[match only on specified contract IDs]: :->contract' + '-J+[match only on specified project IDs]: :->projid' + '-T+[match only on specified task IDs]: :->task' + ) ;; *) - optchars="flvxdnoPgsuUGt" + pgopts=dfGgilnPstUuvx + pkopts=fGgilnPstUuvx ;; esac -# Only keep relevant arguments according to $optchars. -arguments=( ${(M)arguments:#(|\*)(|\(*\))-[$optchars]*} - '*:process name:->pname') -if [[ $service == 'pkill' ]]; then - arguments+=('-'${^signals}'[signal]') + +if [[ $service == pgrep ]]; then + arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pgopts]*} ) +else + arguments=( ${(M)arguments:#((#s)|*\))(\*|)-[$pkopts]*} ) + + # Signals on non-Linux systems can only be completed as the first argument + (( CURRENT != 2 )) && [[ $OSTYPE != linux* ]] && no='!' + + # This is used for exclusion with --signal + sig_arguments=( + '(ss)' ) + + # This is very similar to _signals, but i've avoided it here because it + # doesn't behave the way i want it to + sig_arguments+=( $no'(--signal)-'${^signals[2,-3]} ) + sig_arguments+=( '!(--signal)-'{0..$(( $#signals - 3 ))} ) + + # Complete the -SIG* variant if it's requested + if [[ $PREFIX$SUFFIX == -S* ]]; then + sig_arguments+=( '(--signal)-SIG'${^${(@)signals[2,-3]:#<->}} ) + else + sig_arguments+=( '!(--signal)-SIG'${^${(@)signals[2,-3]:#<->}} ) + fi fi -_arguments -C -s -w $arguments && ret=0 +arguments+=( $sig_arguments + o '*: :->pname' ) + +[[ $OSTYPE == linux* ]] || aopts+=( -A '*-' ) +_arguments -C -s -S $aopts : $arguments && ret=0 + +# complete comma-separated list of various IDs +# $1: tag, $2: description, $3: keyword for 'ps -o' +_pgrep_sequence () { + _sequence _wanted $1 expl "$2" \ + compadd - ${(un)$(_call_program $1 ps -A -o $3=)} +} case $state in (sid) if [[ $OSTYPE == openbsd* ]]; then - break - fi - - compset -P '*,' - - local -a used sid - used=(${(s:,:)IPREFIX}) - if [[ $OSTYPE == freebsd* ]]; then - sid=(${(uon)$(ps -ax -o sid=)}) + _message 'session ID' else - sid=(${(uon)$(ps -A -o sid=)}) + _pgrep_sequence session-ids 'session ID' sid fi - - _wanted sid expl 'session id' compadd -S ',' -q -F used $sid ;; - (ppid) - compset -P '*,' - - local -a used ppid - used=(${(s:,:)IPREFIX}) - if [[ $OSTYPE == (freebsd|openbsd|darwin)* ]]; then - ppid=(${(uon)$(ps -ax -o ppid=)}) - else - ppid=(${(uon)$(ps -A -o ppid=)}) - fi - - _wanted ppid expl 'parent process id' compadd -S ',' -q -F used $ppid + _pgrep_sequence ppids 'parent process ID' ppid ;; - (pgid) - compset -P '*,' - - local -a used pgid - used=(${(s:,:)IPREFIX}) - if [[ $OSTYPE == (freebsd|openbsd|darwin)* ]]; then - pgid=(${(uon)$(ps -ax -o pgid=)}) - else - pgid=(${(uon)$(ps -A -o pgid=)}) - fi - - _wanted pgid expl 'process group id' compadd -S ',' -q -F used $pgid + _pgrep_sequence pgids 'process group ID' pgid ;; - (projid) - compset -P '*,' - - local -a used projid - used=(${(s:,:)IPREFIX}) - projid=(${(uon)$(ps -A -o project=)}) - - _wanted projid expl 'project id' compadd -S ',' -q -F used $projid + _pgrep_sequence project-ids 'project ID' project ;; - (contract) - compset -P '*,' - - local -a used ctid - used=(${(s:,:)IPREFIX}) - ctid=(${(uon)$(ps -A -o ctid=)}) - - _wanted ctid expl 'contract id' compadd -S ',' -q -F used $ctid + _pgrep_sequence contract-ids 'contract ID' ctid ;; - (task) - compset -P '*,' - - local -a used taskid - used=(${(s:,:)IPREFIX}) - taskid=(${(uon)$(ps -A -o project=)}) - - _wanted taskid expl 'task id' compadd -S ',' -q -F used $taskid + _pgrep_sequence task-ids 'task ID' taskid ;; - (pname) local ispat="pattern matching " if (( ${+opt_args[-x]} )); then ispat="" fi - - local command if (( ${+opt_args[-f]} )); then - if [[ "$OSTYPE" == freebsd* ]] && (( ${+opt_args[-S]} )); then - command="$(ps -axH -o command=)" - elif [[ "$OSTYPE" == (freebsd|openbsd|darwin)* ]]; then - command="$(ps -ax -o command=)" - elif [[ "$OSTYPE" == solaris* ]]; then - command="$(ps -A -o args=)" - else - command="$(ps -A o cmd=)" - fi - _wanted pname expl $ispat'process command line' compadd ${(u)${(f)${command}}} + _wanted process-args expl $ispat'process command line' \ + compadd ${${(f)"$(_call_program process-args ps -A -o args=)"}% *} else - if [[ "$OSTYPE" == freebsd* ]] && (( ${+opt_args[-S]} )); then - command="$(ps -axcH -o command=)" - elif [[ "$OSTYPE" == (freebsd|openbsd|darwin)* ]]; then - command="$(ps -axc -o command=)" - elif [[ "$OSTYPE" == solaris* ]]; then - command="$(ps -A -o comm=)" - else - command="$(ps -A co cmd=)" - fi - _wanted pname expl $ispat'process name' compadd ${(u)${(f)${command}}} + _wanted processes-names expl $ispat'process name' _process_names -a -t fi ;; - esac && ret=0 return ret diff --git a/Completion/Unix/Command/_php b/Completion/Unix/Command/_php index d03f3395e..c4c4ab3e2 100644 --- a/Completion/Unix/Command/_php +++ b/Completion/Unix/Command/_php @@ -1,71 +1,177 @@ -#compdef php +#compdef php -P php[0-9.-] -# PHP 5.0.4 (cli) -# PHP 4.3.11 (cli) +# Notes: +# - We make no distinction between internal and user functions +# - We don't complete CGI options, which are rarely used interactively +# - Exclusivity on some of the miscellaneous options isn't very accurate +# - @todo Arguments to an -f script aren't completed accurately -- we need to +# massage words/CURRENT so that the -f arg becomes words[1], but if we just +# leave it at that the output will break if the script has any options of its +# own. We would want to complete script options only following `--`, as in +# `php -f /bin/foo -- -<TAB>` -local curcontext="$curcontext" line state expl -typeset -A opt_args +# Complete PHP class names +(( $+functions[_php_classes] )) || +_php_classes() { + local cmd + local -a tmp -local -a args -local exclusions php_suffix + cmd='foreach ( get_declared_classes() as $c ) { echo "$c\n"; }' + tmp=( ${(f)"$( _call_program classes $words[1] -r ${(q)cmd} )"} ) -zstyle -s ":completion:${curcontext}:" suffixes php_suffix '|' || php_suffix='php|phar' -local php_files=":PHP file:_files -g '*.($php_suffix)(-.)'" + _wanted -x classes expl 'PHP class' compadd -a "$@" - tmp +} + +# Complete PHP extensions/module names; use --zend for Zend extensions only +(( $+functions[_php_extensions] )) || +_php_extensions() { + local idx + local -a expl zend tmp + + zparseopts -a zend -D -E -- -zend + + # `php -m` lists all extensions under two sections called '[PHP Modules]' and + # '[Zend Modules]'. An extension can (but won't necessarily) exist under both + # of these at the same time + tmp=( ${(f)"$( _call_program extensions $words[1] -m )"} ) + idx=${tmp[(i)\[Zend Modules\]]} + + # Get only Zend extensions (for --rz) + if (( $#zend )); then + tmp=( ${(@)tmp[(idx+1),-1]} ) + # Get PHP extensions (for everything else) + else + tmp=( ${(@)tmp[2,(idx-1)]} ) + fi + + _wanted -x extensions expl 'PHP extension' compadd -a "$@" - tmp +} + +# Complete PHP function names +(( $+functions[_php_functions] )) || +_php_functions() { + local cmd + local -a expl tmp + + cmd=' + foreach ( get_defined_functions() as $a ) { + foreach ( $a as $f ) { + echo "$f\n"; + } + } + ' + tmp=( ${(f)"$( _call_program functions $words[1] -r ${(q)cmd} )"} ) + + _wanted -x functions expl 'PHP function' compadd -a "$@" - tmp +} + +_php() { + local curcontext=$curcontext php_suffix php_files ret=1 + local -a context expl line state state_descr args + local -A opt_args + + zstyle -s ":completion:${curcontext}:" suffixes php_suffix '|' || + php_suffix='php|php5|phar' + + php_files=":PHP file:_files -g '*.($php_suffix)(#q-.)'" -if _pick_variant php5=PHP\ 5 php4 --version; then - exclusions="-B --process-begin -R --process-code -F --process-file -E --process-end" args=( - '(-B --process-begin -f --file -r --run 1)'{-B,--process-begin}'[run specified PHP code before processing input lines]:PHP code:' - '(-R --process-code -F --process-file -f --file -r --run 1)'{-R,--process-code}'[run specified PHP code for every input line]:PHP code:' - '(-F --process-file -R --process-code -f --file -r --run 1)'{-F,--process-file}'[parse and execute specified file for every input line]'$php_files - '(-E --process-end -f --file -r --run 1)'{-E,--process-end}'[run specified PHP code after processing all input lines]:PHP code:' - '(-H --hide-args)'{-H,--hide-args}'[hide any passed arguments from external tools]' + + mc # Misc. options + '(-a --interactive)'{-a,--interactive}'[run interactively]' + '*'{-d+,--define=}'[define INI directive]: :->directive' + '(-e --profile-info)'{-e,--profile-info}'[generate extended information for debugger/profiler]' + '(-H --hide-args)'{-H,--hide-args}'[hide script name and arguments from external tools]' + '(fi im pb pf rf rn sc sv *)--ini[display configured INI paths]' + # Note: PHP does not automatically prepend extension_dir to extension file + # names (the way it does when parsing the INI file) at the command line + '*'{-z+,--zend-extension=}'[load specified Zend extension]:Zend extension:_files -g "*.so(|.*)(#q-.)"' + + + '(fi)' # File arguments + "(im pb pf rf sv)"{-f+,--file=}'[parse and/or execute specified file]'$php_files + '(-)1'$php_files + + + '(hv)' # Help/version options; kept separate by convention + '(- 1 *)'{-h,--help}'[display help information]' + '(- 1 *)'{-v,--version}'[display version information]' + '!(- 1 *)'{-\?,-\\\?,--usage} + + + '(im)' # Info/module options (exclusive with everything but -c/-n) + '(fi mc pb pf rf rn sc sv *)'{-i,--info}'[display configuration information (phpinfo())]' + '(fi mc pb pf rf rn sc sv *)'{-m,--modules}'[display installed extensions]' + + + '(in)' # php.ini set/disable options (unrelated to --ini!) + {-c+,--php-ini=}'[specify php.ini or containing directory]:INI file or directory:_files -g "*.ini(-.)"' + {-n,--no-php-ini}'[ignore php.ini]' + + + '(pb)' # Input-processing begin/end options + '(-B --process-begin fi im rf rn sc sv)'{-B+,--process-begin=}'[run specified PHP code before processing input lines]:PHP code:' + '(-E --process-end fi im rf rn sc sv)'{-E+,--process-end=}'[run specified PHP code after processing input lines]:PHP code:' + + + '(pf)' # Input-processing options + '(fi im rf rn sc sv)'{-R+,--process-code=}'[run specified PHP code for every input line]:PHP code:' + '(fi im rf rn sc sv)'{-F+,--process-file=}'[parse and execute specified file for every input line]'$php_files + + + '(rf)' # Reflection options + '(fi im rn pb pf sc sv *)'{--rc=,--rclass=}'[display information about specified class]: :_php_classes' + '(fi im rn pb pf sc sv *)'{--re=,--rextension=}'[display information about specified extension]: :_php_extensions' + '(fi im rn pb pf sc sv *)'{--rf=,--rfunction=}'[display information about specified function]: :_php_functions' + '(fi im rn pb pf sc sv *)'{--ri=,--rextinfo=}'[display configuration information about specified extension]: :_php_extensions' + '(fi im rn pb pf sc sv *)'{--rz=,--rzendextension=}'[display information about specified Zend extension]: :_php_extensions --zend' + + + '(rn)' # Run-script options + "(fi im pb pf rf sc sv)"{-r+,--run=}'[run specified PHP code]:PHP code:' + + + '(sc)' # Source-checking/formatting options + '(im pb pf rf rn sv *)'{-l,--syntax-check}'[check syntax only (lint)]' + '(im pb pf rf rn sv *)'{-s,--syntax-highlight}'[display HTML syntax-highlighted source]' + '!(im pb pf rf rn sv *)--syntax-highlighting' + '(im pb pf rf rn sv *)'{-w,--strip}'[display source stripped of comments and whitespace]' + + + sv # Built-in Web server options + '(-S --server fi im pb pf rf rn sc *)'{-S+,--server=}'[start Web server on specified address/port]: :->server' + '(-t --docroot fi im pb pf rf rn sc *)'{-t+,--docroot=}'[specify Web-server document root]:document root:_directories' + + + ar # Script-argument operands + '(-)*:: :->argument' ) -fi - -args+=( - '(-a --interactive)'{-a,--interactive}'[run interactively]' - '(-c --php-ini -n --no-php-ini)'{-c,--php-ini}'[look for php.ini file in the specified directory]:INI file or directory:_files -g "*.ini(-.)"' - '(-c --php-ini -n --no-php-ini)'{-n,--no-php-ini}'[no php.ini file will be used]' - '(-d --define)'{-d,--define}'[define INI entry]:configuration directive:->directive' - '(-e --profile-info)'{-e,--profile-info}'[generate extended information for debugger/profiler]' - "(-f --file -r --run $exclusions 1)"{-f,--file}'[parse specified file]'$php_files - '(- 1 *)'{-h,--help}'[display help information]' - '(- 1 *)'{-i,--info}'[PHP information]' - '(- *)'{-l,--syntax-check}'[syntax check only (lint)]' - '(- 1 *)'{-m,--modules}'[show compiled in modules]' - "(-r --run -f --file $exclusions -l --syntax-check -s --syntax-highlight -w --strip 1)"{-r,--run}'[run the specified PHP code without using script tags <?..?>]:PHP code:' - '(- 1 *)'{-s,--syntax-highlight}'[display colour syntax highlighted source]' - '(- 1 *)'{-v,--version}'[display version information]' - '(- *)'{-w,--strip}'[display source with stripped comments and whitespace]' - '(-z --zend-extension)'{-z,--zend-extension}'[load specified Zend extension]:extension file:->extension' - '(-)1'$php_files - '(-)*::script argument: _normal' -) - -_arguments -C -s -S "$args[@]" && return 0 - -case $state in - directive) - local -a directives suf - local code='foreach (ini_get_all() as $k => $v) { echo "$k\n"; }' - directives=( $(_call_program directives $words[1] -r ${(q)code} 2>/dev/null) ) - if compset -P 1 '*='; then - _default && return 0 - else - compset -S '=*' || suf=( -qS '=' ) - _wanted directives expl 'configuration directive' compadd "$suf[@]" -a directives && return 0 - fi - ;; - extension) - local -a paths - if [[ -r /etc/ld.so.conf ]]; then - paths=( ${(f)"$(</etc/ld.so.conf)"} ) - else - paths=(.) - fi - _wanted extensions expl 'zend extension' _files -W paths -g "*.so(|.*)(-.)" && return 0 - ;; -esac - -return 1 + + _arguments -C -s -S : $args && ret=0 + + case $state in + argument) + if [[ -n $opt_args[(i)(pb|pf|rn)-*] ]]; then + _description files expl 'script argument' + _files "${(@)expl}" && ret=0 + else + _normal && ret=0 + fi + ;; + directive) + local -a directives suf + local code='foreach (ini_get_all() as $k => $v) { echo "$k\n"; }' + directives=( ${(f)"$( + _call_program directives $words[1] -r ${(q)code} + )"} ) + if compset -P 1 '*='; then + _default && ret=0 + else + compset -S '=*' || suf=( -qS '=' ) + _wanted directives expl 'INI directive' \ + compadd "$suf[@]" -a directives && ret=0 + fi + ;; + server) + if compset -P '*:'; then + _wanted -2V port-numbers expl 'port number' \ + compadd 80 81 443 591 8000 8001 8008 8080 8443 && ret=0 + ret=0 + else + _wanted hosts expl 'local address' _bind_addresses -0bhK -qS: && ret=0 + fi + ;; + esac + + return ret +} + +_php "$@" diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps index a8208a365..72e711227 100644 --- a/Completion/Unix/Command/_ps +++ b/Completion/Unix/Command/_ps @@ -31,7 +31,7 @@ args=( '*-G+[select processes by real group]:group:_sequence -s , _groups' '*-g+[select processes by effective group or session]:group:_sequence -s , _groups' '*-s+[select processes by session leaders]:session leader:_sequence -s , _pids' - '*-t+[select processes by attached terminal]:tty:_sequence -s , _ttys -D' + '*-t+[select processes by attached terminal]:tty:_sequence -s , _ttys -Do' '*-u+[select processes by effective user]:user:_sequence -s , _users' '*-U+[select processes by real user]:user:_sequence -s , _users' '-o+[specify output format]:property:_sequence -s , _ps_props -' @@ -211,7 +211,7 @@ if (( CURRENT > 1 )) && [[ $OSTYPE != (solaris*|linux-gnu) || *J) _sequence _jails -0 && return ;; *[MNW]) _files && return ;; *t) - _wanted -C option-t-1 ttys expl tty _sequence -s , _ttys -D && return + _wanted -C option-t-1 ttys expl tty _sequence -s , _ttys -Do && return ;; *[pq]) _wanted -C "option-${words[CURRENT-1][-1]}-1" processes \ expl 'process ID' _sequence -s , _pids && return ;; diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf index 282431462..ce78baf27 100644 --- a/Completion/Unix/Command/_readelf +++ b/Completion/Unix/Command/_readelf @@ -7,6 +7,7 @@ _pick_variant -r variant elftoolchain=elftoolchain elfutils=elfutils binutils -- args=( '(-a --all)'{-a,--all}'[show all tables]' + '(-g --section-groups)'{-g,--section-groups}'[show section groups]' '(-h --file-header)'{-h,--file-header}'[show file header]' '(-l --program-headers --segments)'{-l,--program-headers,--segments}'[show program headers]' '(-S --section-headers --sections)'{-S,--section-headers,--sections}'[show sections header]' @@ -31,7 +32,6 @@ args=( case $variant in elftoolchain|binutils) args+=( - '(-g --section-groups)'{-g,--section-groups}'[show section groups]' '(-t --section-details)'{-t,--section-details}'[show section details]' '(-e --headers)'{-e,--headers}'[show file, program and sections headers]' '(-s --syms --symbols)'{-s,--syms,--symbols}'[show symbol table]' @@ -49,6 +49,7 @@ case $variant in ;; elfutils) args+=( + '--dwarf-skeleton=[find skeleton compile units (with -w)]:file:_files' '--elf-section[used specified section as ELF input data]::section' '(-e --exception)'{-e,--exception}'[show sections for exception handling]' '(-N --numeric-addresses)'{-N,--numeric-addresses}"[don't find symbol names for addresses in DWARF data]" diff --git a/Completion/Unix/Command/_readlink b/Completion/Unix/Command/_readlink new file mode 100644 index 000000000..36bd43752 --- /dev/null +++ b/Completion/Unix/Command/_readlink @@ -0,0 +1,48 @@ +#compdef readlink greadlink + +local variant ret=1 +local -a context line state state_descr args copts aopts=( -A '-*' ) +local -A opt_args + +# We can't use groups here because it would complicate the option filtering +copts=( -e -f -m --canonicalize --canonicalize-existing --canonicalize-missing ) + +args=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' + # Delimiter options + # (Note: GNU `readlink` won't let you use -n with multiple files) + '(-n -z --no-newline --zero)'{-n,--no-newline}'[suppress trailing newline]' + '(-n -z --no-newline --zero)'{-z,--zero}'[use NUL as output delimiter]' + # Verbosity options + '(-q -s -v --quiet --silent --verbose)'{-q,-s,--quiet,--silent}'[suppress most error messages]' + '(-q -s -v --quiet --silent --verbose)'{-v,--verbose}'[show error messages]' + # Canonicalisation options + "(${(j< >)copts})"{-e,--canonicalize-existing}'[canonicalize paths (all components must exist)]' + "(${(j< >)copts})"{-f,--canonicalize}'[canonicalize paths]' + "(${(j< >)copts})"{-m,--canonicalize-missing}'[canonicalize paths (components may be missing)]' +) + +# Filter out non-GNU options if applicable +if _pick_variant gnu='Free Soft' unix --version; then + aopts=( ) +else + case $OSTYPE in + darwin*) args=( ${(@M)args:#(|*\))-[n]\[*} ) ;; + netbsd*) args=( ${(@M)args:#(|*\))-[fnqsv]\[*} ) ;; + dragonfly*|*bsd*) args=( ${(@M)args:#(|*\))-[fn]\[*} ) ;; + *) args=( ) ;; + esac +fi + +_arguments -s -S $aopts : $args '*: :->files' && ret=0 + +# File arguments must be symlinks unless a canonicalisation option is given +[[ $state == files ]] && +if [[ ${opt_args[(i)(${~${(j<|>)copts}})]} ]]; then + _files && ret=0 +else + _files -g '*(@)' && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_rmdir b/Completion/Unix/Command/_rmdir new file mode 100644 index 000000000..0f5e16912 --- /dev/null +++ b/Completion/Unix/Command/_rmdir @@ -0,0 +1,23 @@ +#compdef rmdir grmdir + +local -a args + +args=( + '(-p --parents)'{-p,--parents}'[remove each component of the specified paths]' +) + +if _pick_variant gnu=GNU unix --version; then + args+=( + '--ignore-fail-on-non-empty[ignore failure if directory is non-empty]' + '(-v --verbose)'{-v,--verbose}'[be verbose]' + ) +else + args=(${args:#*\)--*}) + if [[ $OSTYPE == (dragonfly|freebsd)* ]]; then + args+=('-v[be verbose]') + fi +fi + +_arguments -s -S -A '-*' \ + $args \ + '*:directories:_directories' diff --git a/Completion/Unix/Command/_samba b/Completion/Unix/Command/_samba index faad69ba4..9a2fea9d6 100644 --- a/Completion/Unix/Command/_samba +++ b/Completion/Unix/Command/_samba @@ -1,93 +1,112 @@ #compdef smbcontrol smbclient nmblookup smbstatus -local expl msgs args +local curcontext="$curcontext" ret=1 +local -a state line expl msgs args ign + +(( CURRENT == 2 )) || ign='!' +args=( + '(-d --debuglevel)'{-d+,--debuglevel=}'[set debug level]:debug level (1..10) [1]' + '(-s --configfile)'{-s+,--configfile=}'[specify alternate smb.conf file]:config file:_files' + '(-l --log-basename)'{-l+,--log-basename=}'[specify base name for log files]:base name:_files' + '*--option=[set smb.conf option from command line]:option=value' + "${ign}(1 2 3 -)"{-\?,--help}'[display usage information]' + "${ign}(1 2 3 -)--usage[display brief usage information]" + "${ign}(1 2 3 - *)"{-V,--version}'[display version information]' +) case $service in smbcontrol) - case $CURRENT in - 3) - msgs=( debug ping profile debuglevel profilelevel ) - case $words[CURRENT-1] in - nmbd) msgs=( $msgs force-election ) ;; - smbd) msgs=( $msgs printer-notify ) ;; - -i) return 1 ;; - esac - _wanted message-type expl 'message types' compadd -a msgs - ;; - 4) - case $words[CURRENT-1] in - profile) - _wanted parameter expl 'parameter' compadd on off flush count - ;; - debug) _message -e levels 'debug level' ;; - ping) _message -e numbers 'number of ping messages' ;; - esac + _arguments -C -S $args \ + '(-t --timeout)'{-t+,--timeout=}'[set timeout]:timeout (seconds)' \ + ':destination:(all nmbd smbd winbindd)' \ + ':message type:->message-types' \ + ':parameter:->parameters' && ret=0 + + case $state in + message-types) + msgs=( ${${${${${(f)"$(_call_program message-types smbcontrol -\? 2>&1)"}[(r)<message-type*,-1]}[2,-1]#?}/ ##(#b)(?)/:$match:l}%:( |\(null\))} ) + _describe -t message-types 'message type' msgs -M 'r:|-=* r:|=*' && ret=0 ;; - *) - _arguments \ - '-i[run interactively]' \ - ':destination:(nmbd smbd)' + parameters) + case $line[2] in + profile) + _wanted parameter expl 'parameter' compadd on off flush count && ret=0 + ;; + debug) _message -e levels 'debug level' ;; + ping) _message -e numbers 'number of ping messages' ;; + esac ;; esac + return ret ;; smbclient) - args=( - '(-N -A)2:password' - '(2)-s+[specify location of smb.conf]:smb.conf location:_files' - '(2)-O+[specify socket options]:socket options' - '(2)-R+[specify name resolution order]:name resolution order:_values -s " " "name resolution order" lmhosts host wins bcast' - '(2 -L -D -T)-M+[send message]:host:_hosts' - '(2)-i+[specify NetBIOS scope]:scope' - '(2)-N[suppress password prompt]' - '(2)-n+[specify local NetBIOS name]:local machine name' - '(2)-d+[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' - '(2)-p+[specify tcp port]:tcp port' - '(2)-l+[specify base log filename]:base log filename' - '(2)-I+[specify IP address of server]:IP address' - '(2)-E[output messages to stderr]' - '(2)-U+[specify username]:username:_users' - '(2)-A+[specify file containing username/password]:file:_files' - '(2 -M -D -T)-L+[list services on server]:host:_hosts' - '(2)-t+[specify terminal code]:terminal code' - '(2)-b+[specify buffersize]:transmit/send buffer size (bytes)' - '(2)-W+[specify workgroup]:workgroup' - '(2 -M -L)-T+[specify tar options]:tar options' - '(2 -M -L)-D+[initial directory]:initial directory' - '(2)-c[specify commands]:command string' + args+=( + '(-N -A)2: :_guard "^-*" password' + '(2 -R --name-resolve)'{-R+,--name-resolve=}'[specify name resolution order]:name resolution order:_values -s " " "name resolution order" lmhosts host wins bcast' + '(2 -M --message -L --list -D --directory -T --tar)'{-M+,--message=}'[send message]:host:_hosts' + '(2 -I --ip-address)'{-I+,--ip-address=}'[specify IP address of server]:IP address' + '(2 -E --stderr)'{-E,--stderr}'[output messages to stderr]' + '(2 -M --message -D --directory -T --tar)'{-L+,--list=}'[list services on server]:host:_hosts' + '(-m --max-protocol)'{-m+,--max-protocol=}'[set the max protocol level]:level' + '(2 -T --tar -M --message -L --list)'{-T+,--tar=}'[specify tar options]:tar options' + '(2 -D --directory -M --message -L --list)'{-D+,--directory=}'[specify initial directory]:initial directory' + '(2 -c --command)'{-c,--command=}'[specify commands]:command string' + '(2 -b --send-buffer)'{-b+,--send-buffer=}'[change transmit/send buffer]:buffer size (bytes) [65520]' + '(-t --timeout)'{-t+,--timeout=}'[change the per-operation timeout]:timeout (seconds)' + '(2 -p --port)'{-p+,--port=}'[specify tcp port]:tcp port' + '(-g --grepable)'{-g,--grepable}'[produce grepable output]' + '(-B --browse)'{-B,--browse}'[browse SMB servers using DNS]' + '(2 -d --debuglevel)'{-d+,--debuglevel=}'[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' + '(2 -O --socket-options)'{-O+,--socket-options=}'[specify socket options]:socket options' + '(2 -n --netbiosname)'{-n+,--netbiosname=}'[specify local NetBIOS name]:local machine name' + '(2 -W --workgroup)'{-W+,--workgroup=}'[specify workgroup]:workgroup' + '(2 -i --scope)'{-i+,--scope=}'[specify NetBIOS scope]:scope' + '(2 -U --user)'{-U+,--user=}'[specify username]:username:_users' + '(2 -N --no-pass)'{-N,--no-pass}'[suppress password prompt]' + '(-k --kerberos)'{-k,--kerberos}'[use kerberos (active directory) authentication]' + '(2 -A --authentication-file)'{-A+,--authentication-file=}'[specify file containing username/password]:file:_files' + '(-S --signing)'{-S+,--signing=}'[set the client signing state]:state:(on off required)' + '(-P --machine-pass)'{-P,--machine-pass}'[use stored machine account password]' + '(-e --encrypt)'{-e,--encrypt}'[encrypt SMB transport]' + '(-C --use-ccache)'{-C,--use-ccache}'[use the winbind ccache for authentication]' + '--pw-nt-hash[the supplied password is the NT hash]' ) - if (( CURRENT == 2 )); then - args=( $args - '1:service name:_hosts -P // -S /' - '(-s -O -R -M -i -N -n -d -p -l -I -E -U -A -L -t -b -W -T -D -c)-h[display usage information]' - ) - fi - _arguments -s "$args[@]" + (( CURRENT == 2 )) && args+=( '1:service name:_hosts -P // -S /' ) + _arguments -s -S $args ;; nmblookup) - _arguments -s -A "-*" \ - '(-h)-R[set recursion desired in packet]' \ - '(-h)-M[search for a master browser]' \ - '(-h)-S[lookup node status as well]' \ - '(-h)-T[perform reverse DNS on IP addresses]' \ - '(-h)-r[use root port 137]' \ - '(-h)-A[query node status on IP address]' \ - '(-R -M -S -T -r -A -B -U -d -s -i *)-h[print help message]' \ - '(-h)-B+[specify broadcast address]:broadcast address' \ - '(-h)-U+[specify unicast address]:unicast address' \ - '(-h)-d+[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' \ - '(-h)-s+[specify location of smb.conf]:smb.conf location:_files' \ - '(-h)-i+[specify NetBIOS scope]:scope' \ - '(-h)*:NetBIOS name:_hosts' + _arguments -s -S $args \ + '(-B --broadcast)'{-B+,--broadcast=}'[specify broadcast address]:broadcast address' \ + '(-f --flags)'{-f,--flags}'[list NMB flags returned]' \ + '(-U --unicast)'{-U+,--unicast=}'[specify unicast address]:unicast address' \ + '(-M --master-browser)'{-M,--master-browser}'[search for a master browser]' \ + '(-R --recursion)'{-R,--recursion}'[set recursion desired in packet]' \ + '(-S --status)'{-S,--status}'[lookup node status as well]' \ + '(-T --translate)'{-T,--translate}'[perform reverse DNS on IP addresses]' \ + '(-r --root-port)'{-r,--root-port}'[use root port 137]' \ + '(-A --lookup-by-ip)'{-A,--lookup-by-ip}'[query node status on IP address]' \ + '(-d --debuglevel)'{-d+,--debuglevel=}'[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' \ + '(-O --socket-options)'{-O+,--socket-options=}'[specify socket options to use]:socket option' \ + '(-n --netbiosname)'{-n+,--netbiosname=}'[specify primary netbios name]:netbios name' \ + '(-W --workgroup)'{-W+,--workgroup=}'[specify workgroup name]:workgroup name' \ + '(-i --scope)'{-i+,--scope=}'[specify NetBIOS scope]:scope' \ + '(h)*:NetBIOS name:_hosts' ;; smbstatus) - args='(-b -d -L -p -S)' - _arguments -s \ - "$args-b[brief output]" \ - "$args-d[detailed output]" \ - "$args-L[list only locks]" \ - "$args-p[list smbd(8) processes]" \ - "$args-S[list only shares]" \ - '-s+[specify location of smb.conf]:smb.conf location:_files' \ - '-u+[specify user to restrict information to]:user:_users' - ;; + _arguments -s -S $args \ + {-b,--brief}'[brief output]' \ + '(-v --verbose)'(-v,--verbose)'[be verbose]' \ + '(-d --debuglevel)'{-d+,--debuglevel=}'[specify debug level]:debug level:(0 1 2 3 4 5 6 7 8 9 10)' \ + '(-u --user)'{-u+,--user=}'[specify user to restrict information to]:user:_users' \ + '(-B --byterange)'{-B,--byterange}'[include byte range locks]' \ + '(-n --numeric)'{-n,--numeric}'[numeric uid/gid]' \ + '(-f --fast)'{-f,--fast}'[skip checks if processes still exist]' \ + + '(output)' \ + {-P,--profile}'[do profiling]' \ + {-R,--profile-rates}'[show call rates]' \ + {-L,--locks}'[list only locks]' \ + {-p,--processes}'[list smbd(8) processes]' \ + {-S,--shares}'[list only shares]' \ + {-N,--notify}'[list only notifies]' + ;; esac diff --git a/Completion/Unix/Command/_scons b/Completion/Unix/Command/_scons new file mode 100644 index 000000000..2c620cc1a --- /dev/null +++ b/Completion/Unix/Command/_scons @@ -0,0 +1,59 @@ +#compdef scons + +_arguments -s -S \ + '(-c --clean --remove)-'{c,-clean,-remove}'[remove specified targets and dependencies]' \ + '(-C --directory)-'{C,-directory=}'[change to specified directory first]:directory:_directories' \ + '--cache-debug=[print CacheDir debug info to file]:file:_files' \ + '(--cache-disable --no-cache)--'{cache-disable,no-cache}"[don't retrieve built targets from cache]" \ + '(--cache-force --cache-populate)--'{cache-force,cache-populate}'[copy already-built targets into cache]' \ + "--cache-readonly[don't update CacheDir with built targets]" \ + '--cache-show[print build actions for files from cache]' \ + '--config=[set Configure mode]:mode:(auto force cache)' \ + '(-u --up --search-up -U)-D[search up for SConstruct; build default targets]' \ + '--debug=[print debugging information]:type:( + count duplicate explain findlibs includes memoizer memory objects pdb prepare presub stacktrace time)' \ + '--diskcheck=[enable specific on-disk checks]:check:(all none match rcs sccs)' \ + '--duplicate=[set preferred file duplication methods]:file duplication methods:( + hard-soft-copy soft-hard-copy hard-copy soft-copy copy)' \ + '(-f --file --makefile --sconstruct)-'{f,-file=,-makefile=,-sconstruct=}'[specify SConstruct file]:file:_files' \ + '(-)-'{h,-help}'[display defined usage information]' \ + '(-)-'{H,-help-options}'[display usage information]' \ + '(-i -ignore-errors)-'{i,-ignore-errors}'[ignore errors from build actions]' \ + \*{-I,--include-dir=}'[add directory to search Python modules]:directories:_directories' \ + '(--implicit-deps-changed --implicit-deps-unchanged)--implicit-cache[cache scanned dependencies]' \ + '(--implicit-cache --implicit-deps-changed)--implicit-deps-changed[rescan dependencies]' \ + '(--implicit-cache --implicit-deps-unchanged)--implicit-deps-unchanged[ignore changes to scanned dependencies]' \ + '--interactive[start interactive mode]' \ + '(-j --jobs)-'{j,jobs=}'[specify no of jobs to run in parallel]' \ + '(-k --keep-going)-'{k,-keep-going}'[continue after an error]' \ + '--max-drift=[set the maximum clock drift]:drift (seconds)' \ + '--md5-chunksize=[set chunksize for MD5 signature computation]:size (kB)' \ + '(-n --just-print --dry-run --recon)-'{n,-just-print,-dry-run,-recon}"[print commands but don't run them]" \ + "--no-site-dir[don't use the usual site_scons directory]" \ + '--profile=[profile scons]:output file:_files' \ + '(-q --question)-'{q,question}'[query whether up-to-date]' \ + '-Q[suppress progress messages]' \ + '--random[build dependencies in random order]' \ + '(-s --silent --quiet)-'{s,-silent,-quiet}"[don't print commands]" \ + '--site-dir=[specify site_scons directory]:directory:_directories' \ + '--stack-size[set stacksize of threads]:size (kB)' \ + '--taskmastertrace=[trace node evaluation to file]:file' \ + '--tree=[print dependency tree]:format:(all derived prune status)' \ + '(-u --up --search-up -D -U)-'{u,-up,-search-up}'[search up for SConstruct; build current directory]' \ + '(-u --up --search-up -D)-U[search up for SConstruct; build Default targets]' \ + '(-)-'{v,-version}'[print version information]' \ + \*{--warn=,--warning=}'[enable or disable warnings]:type:( + all cache-write-error corrupt-sconsign dependency deprecated + deprecated-copy deprecated-source-signatures deprecated-target-signatures + duplicate-environment fortran-cxx-mix link misleading-keywords + missing-sconscript no-md5-module no-metaclass-support no-object-count + no-parallel-support python-version reserved-variable stack-size no-all + no-cache-write-error no-corrupt-sconsign no-dependency no-deprecated + no-deprecated-copy no-deprecated-source-signatures + no-deprecated-target-signatures no-duplicate-environment + no-fortran-cxx-mix no-link no-misleading-keywords no-missing-sconscript + no-no-md5-module no-no-metaclass-support no-no-object-count + no-no-parallel-support no-python-version no-reserved-variable + no-stack-size)' \ + \*{-Y,--repository}'[search specified repository for files]:repository:_files' \ + '*:target:_default' # Doesn't seem to be a simple way to get a list of targets diff --git a/Completion/Unix/Command/_sed b/Completion/Unix/Command/_sed index 15b92a634..f03278364 100644 --- a/Completion/Unix/Command/_sed +++ b/Completion/Unix/Command/_sed @@ -1,15 +1,60 @@ #compdef sed gsed psed s2p -local args inplace extended +local variant inplace extended ign sep separator +local -i nest=0 +local -a args aopts sedexpr cmds_none cmds_slash cmds_end substflags expl bsnl nl labels excl dedup +local -a step range negate mods +aopts=( -A '-*' ) +bsnl=( $'\\\n' ) +nl=$'\n' +compquote nl +cmds_none=( + '{:start group' + 'q:quit after printing pattern space' + 'h:copy pattern space to hold space' + '\::place label' + '#:comment' + '=:print current line number' + 'a:append text' + 'i:insert text' + 'r:append contents of file' + 'b:branch' + 't:branch if s command has been successful' + 'c:replace line with text' + 'l:list current line in visually unambiguous form' + 'w:write pattern space to file' +) +cmds_slash=( + 's:substitute regex' + 'y:transliterate characters' +) +cmds_end=( + 'd:delete pattern space' + 'D:delete up to the first newline in the pattern space' + 'g:copy hold space to pattern space' + 'G:append hold space to pattern space' + 'H:append pattern space to hold space' + 'n:read the next line of input into pattern space' + 'N:append the next line of input to the pattern space' + 'p:print the current pattern space' + 'P:print upto the first newline of the current pattern space' + 'x:exchange hold and pattern spaces' + '}:end group' +) +substflags=( + 'g:replace all matches to the regular expression' + 'p:print new pattern space if substitution made' + 'w:write result to named file if substitution made' +) args=( '(-n --quiet --silent)'{-n,--quiet,--silent}'[suppress automatic printing of pattern space]' - '(1)*'{-e,--expression=-}'[specify sed commands to run]:sed script' - '(1)*'{-f,--file=-}'[add contents of file to commands to run]:file:_files' - '(-e)1: :_guard "^-*" sed script' + '(1)*'{-e+,--expression=}'[specify sed commands to run]:sed script:_sed_expressions' + '(1)*'{-f+,--file=}'[add contents of file to commands to run]:file:_files' + '(-e)1:sed script:_sed_expressions' '*:input file:_files' ) -inplace='[edit files in-place, running scripts separately for each file]::suffix for backup' +inplace='[edit files in-place, running scripts separately for each file]:: :_guard "^(*[@/; ]*|?(#c6,)|-*)" "suffix for backup"' extended='[use extended regular expressions]' if [[ $service = (psed|s2p) ]]; then @@ -17,40 +62,193 @@ if [[ $service = (psed|s2p) ]]; then "${(@)args:#(|\(*\))(|\*)--*}" '-a[delay opening files listed with w function]' ) -elif _pick_variant gnu=GNU unix --version; then +elif _pick_variant -r variant gnu=GNU unix --version; then + aopts=( ) + (( $#words > 2 )) && ign='!' args+=( '--follow-symlinks[follow symlinks when processing in place]' - '(-i --in-place)'{-i-,--in-place=-}$inplace + '(-i --in-place -s --separate)'{-i-,--in-place=-}$inplace '(-c --copy)'{-c,--copy}'[copy instead of rename when shuffling files in in-place mode]' - '(-l --line-length)'{-l,--line-length=-}'[specify line-wrap length for the l command]' + '(-l --line-length)'{-l+,--line-length=}'[specify line-wrap length for the l command]' '(-r)--posix[disable GNU extensions]' '(-E -r --regexp-extended)'{-E,-r,--regexp-extended}$extended '(-s --separate)'{-s,--separate}'[consider files separately instead of as a combined stream]' '--sandbox[block commands that can affect the system (r/w/W/e)]' '(-u --unbuffered)'{-u,--unbuffered}'[disable data buffering]' '(-z --null-data)'{-z,--null-data}'[separate lines by NUL characters]' - '(- 1 :)--help[print program usage]' - '(- 1 :)--version[print program version]' + "${ign}(- 1 :)--help[print program usage]" + "${ign}(- 1 :)--version[print program version]" ) + if [[ -z ${words[(r)--posix]} ]]; then + cmds_none+=( + 'R:append a line from file' + 'T:branch if no s command has been successful' + 'W:write the first line of pattern space to file' + 'v:fail if GNU extensions not supported or older than specified version' + ) + cmds_end+=( + "e:execute a command and include it's output" + 'F:print the filename of the current input file' + 'Q:quit' + 'z:empty the pattern space' + ) + substflags+=( + 'e:execute pattern space as a command and replace with result' + {i,I}':case-insensitive regular expression matching' + {m,M}':multi-line matching' + ) + fi else args=( "${(@)args:#(|\(*\))(|\*)--*}" ) case $OSTYPE in openbsd*|freebsd*|netbsd*|darwin*|dragonfly*) args+=( - '(-r -E)'{-r,-E}$extended + '(-r -E)'-E$extended '-a[delay opening files listed with w function]' ) ;| - darwin*|freebsd*|netbsd*|openbsd*) args+=( '-i'$inplace ) ;| + openbsd*|freebsd*|netbsd*|dragonfly*) args+=( '(-r -E)'-r$extended ) ;| + darwin*|freebsd*|netbsd*|openbsd*) args+=( '-i+'$inplace ) ;| darwin*|freebsd*|netbsd*) args+=( '-l[make output line buffered]' ) ;| freebsd*) args+=( '-u[disable data buffering]' ) ;| freebsd*|netbsd*) args+=( - '-I[edit files in-place, treating all files as a single input stream]::suffix for backup' + '-I+[edit files in-place, treating all files as a single input stream]:: :_guard "^(*[@/; \\\]*|?(#c6,)|-*)" "suffix for backup"' ) ;; openbsd*) args+=( '-u[make output line buffered]' ) ;; esac fi -_arguments -s "$args[@]" +zstyle -s ":completion:${curcontext}:address-forms" list-separator separator || separator=-- +step=( "~ $separator step" ) +negate=( "! $separator negated" ) +range=( ", $separator range" ) +mods=( "I $separator case-insensitive" "M $separator multi-line" ) + +sedexpr=( + \( /$'*\0[ \t\n]#'/ \) # strip off any preceding arguments - handled by _arguments + \( + # Handle an optional address range + \( + \( + \( + '///' '/[^/]#//' ':regexes:regex:' # skip /pattern/ + \| + '/\\(?)/' -'sep=${match#?}' # handle \xpatternx + \( '/\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# '/?/' -'[[ $match = $sep ]]' ':regexes:regex:' + \) + $'/[ \t]#/' + \( \| '/[IM]##/' -'dedup=( ${(s..)match} )' ':address-forms:address form:compadd -S "" -d mods -F dedup I M' \) \# + \| + '/([0-9]##|$)[ \t]#/' # line number + \( + '/\~[ \t]#/' # addr1~N + '/[0-9]##[ \t]#/' ': _message -e steps "number - match where line number is a multiple"' + \| '//' ':address-forms:address form:compadd -S "" -d step \~' \) + \| + '/[]/' ': _guard "^([sy]|[^0-9$/\\\]*)" "address - line number or /pattern/"' + \) + \( # range end, also optional + '/[ \t]#,[ \t]#/' -'excl=( \\\# : )' # exclude comments and labels after ranges + \( + '///' '/[^/]#//' ':regexes:regex:' # handle /pattern/ + \| + '/\\(?)/' -'sep=${match#?}' # handle \xpatternx + \( '/\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# '/?/' -'[[ $match = $sep ]]' ':regexes:regex - 2:' + \| + '/+[ \t]#/' # addr1,+N + '/[0-9]##/' ': _message -e number "number of following lines"' + \| + '/\~[ \t]#/' # addr1,~N + '/[0-9]##/' ': _message -e number "following lines until line number is a multiple of specified number"' + \| + '/([0-9]##|$)/' # line number + \| + '/[]/' ': _message -e ranges "ending line - [+~]number, $ or /pattern/"' + \) + \| + '//' -'excl=( \\\# : )' ':address-forms:address form:compadd -S "" -d range ,' + \) + \( + '/!/' ':address-forms:address form:compadd -S "" -d negate !' + \| \) + \| // -'excl=( \{ )' \) # { ... } is only useful following a range so exclude { + + $'/[ \t]#/' -'(( nest )) || excl+=( \} )' # whitespace + exclude } without preceding { + \( # First commands, for which the pattern fully terminates them + '/e[ \t]#/' $'/((\\\n|\\[^\n]|[^\\\n])##\n|[\n;])/' ':commands:command:_cmdstring' # GNU extension + \| + $'/{[ ;\t\n]#/' -'((++nest,1))' # opening brace + \| + '/\#/' # comments + $'/[^\n]##\n[\n; \t]#/' ':comments:comment:' + \| + $'/[aci]/' # a, c and i commands + \( + $'/[ \t]#/' -'[[ $variant = gnu && $+opt_args[--posix] = 0 ]]' # GNU allows, e.g. 'c string' + \| + $'/[ \t]#/' $'/\\\n/' ':newlines:newline:compadd -Q -S "" "$bsnl"' + \) + $'/(\\\n|\\[^\n]|[^\\\n])##\n[\n; \t]#/' ':strings:string:' + \| + $'/[RrwW][ \t]#/' $'/[^\n]##\n[\n; \t]#/' ':files:file:_files -S ""' + \| # Now commands with shared termination handling + \( + # branches/labels, GNU sed allows an empty label + $'/[:btT][ \t]#/' $'/[^ \t\n;]#/' $'%[ \t\n;]%' -'labels+=( $match )' + ':labels:label: _wanted -x labels expl label compadd -S "" -a labels' + \| + '/l/' $'/[ \t]#<->/' ':width:width:' + \| + '/s(?)/' -'sep=${match#s}' # Substitutions + \( '/\\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# + '/?/' -'[[ $match = $sep ]]' ':regexes:source regex:' + \( '/\\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# + '/?/' -'[[ $match = $sep ]]' ':regexes:substitute string (back-references with & and \1 .. \9):' + \( # Substitution flags + $'/w[ \t]#/' $'/[^\n]##/' $'%\n%' ':files:file:_files -S ""' + \| + # pass existing flags, building exclusion list from them + $'/[gpiImM0-9]#/' -'excl=( ${(s..)${${${match/[iI]/iI}/[mM]/mM}}/e/ew} )' + \( + '//' -'[[ -z ${excl[(r)[0-9]]} ]]' # exclude if numbers already there + '//' '%[^egpiImM0-9]%' ': _message -e numbers "number - substitute nth match"' + \| + '//' '%[^egpiImM0-9]%' $':flags:flag: _describe -t flags flag substflags -S "" -F excl' + \) + \) + \| + '/y(?)/' -'sep=${match#y}' # Character transliterations + \( '/\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# '/?/' -'[[ $match = $sep ]]' ':source:source:' + \( '/\?/' \| '/?/' -'[[ $match != $sep ]]' \) \# '/?/' -'[[ $match = $sep ]]' ':dest:dest:' + \| + '/[qQ]/' -'[[ $variant = gnu && $+opt_args[--posix] = 0 ]]' + $'/[\t ]#<->/' '%[^0-9]%' ':exit-codes:exit code:' + \| + '/[=dDFhHgGnNpPqQxz]/' # stand-alone commands that take no argument + \( $'/[ \t]#/' $'%[#\n;}]%' \| $'/[ \t]/' '/[]/' ': _message "no arguments"' \| \) + \| + $'/v[ \t]#/' $'/[^\n;}]#/' $'%[\n;}]%' ':versions:version:' + \| + $'/}[ \t]#/' -'((--nest,1))' # closing } + \| + /'[]'/ ':commands:command: _describe -t sed-commands "sed command" cmds_none -S "" -F excl -- cmds_slash -S / -- cmds_end -F excl -r \; -S $nl' + \) + $'/[ \t]#/' + \( $'/}[ \t]#/' -'((--nest,1))' \| \) # closing } is allowed by GNU sed without preceding ; or newline + \( + '/\#/' $'/[^\n]##\n[\n; \t]#/' ':comments:comment:' # line end comments + \| + # add in and auto-removable newline if command is terminated + $'/[;\n][ ;\t\n]#/' $':separators:separator:compadd -r ";" -S $nl ""' + \| + $'/{[ \t]#/' -'((++nest,1))' # opening {, keep count of nesting level + \) + \) + \) \# +) + +_regex_arguments _sed_expressions "$sedexpr[@]" + +_arguments -s -S $aopts : "$args[@]" diff --git a/Completion/Unix/Command/_sh b/Completion/Unix/Command/_sh index 2afb46621..39d299c58 100644 --- a/Completion/Unix/Command/_sh +++ b/Completion/Unix/Command/_sh @@ -1,4 +1,4 @@ -#compdef sh ksh bash csh tcsh rc +#compdef sh ash csh dash ksh ksh88 ksh93 mksh oksh pdksh rc tcsh yash if (( CURRENT == ${words[(i)-c]} + 1 )); then _cmdstring diff --git a/Completion/Unix/Command/_shasum b/Completion/Unix/Command/_shasum new file mode 100644 index 000000000..950a47763 --- /dev/null +++ b/Completion/Unix/Command/_shasum @@ -0,0 +1,24 @@ +#compdef shasum -P shasum(|5).* + +# This function covers the `shasum` script included with Perl (and notably the +# primary SHA digest tool on macOS). See `_md5sum` for the GNU digest utilities +# and `_cksum` for the BSD ones. +# +# @todo It's possible that someone could symlink this script to `sha1sum` or +# whatever; we might want to detect that some day. + +_arguments -s -S : \ + '(: -)'{-h,--help}'[display help information]' \ + '(: -)'{-v,--version}'[display version information]' \ + + '(sum)' \ + '(chk)'{-0,--01}'[read in BITS mode]' \ + '(chk)'{-b,--binary}'[read in binary mode]' \ + '(chk)'{-p,--portable}'[read in portable mode]' \ + '(chk)'{-t,--text}'[read in text mode]' \ + + 'chk' \ + '(sum)'{-c,--check}'[verify checksums from input files]' \ + '(sum -s -w --status --warn)'{-s,--status}'[suppress all output]' \ + '(sum -s -w --status --warn)'{-w,--warn}'[warn about each improperly formatted checksum line]' \ + + misc \ + '(-a --algorithm)'{-a+,--algorithm=}'[specify algorithm]:algorithm:(1 224 256 384 512 512224 512256)' \ + '*: :_files' diff --git a/Completion/Unix/Command/_shuf b/Completion/Unix/Command/_shuf new file mode 100644 index 000000000..83f42e6d3 --- /dev/null +++ b/Completion/Unix/Command/_shuf @@ -0,0 +1,28 @@ +#compdef shuf gshuf + +local ret=1 +local -a context line state state_descr +local -A opt_args + +_arguments -s -S : \ + '(: -)--help[display help information]' \ + '(: -)--version[display version information]' \ + '(-n --head-count)'{-n+,--head-count=}'[limit output to specified number of lines]:output line limit' \ + '(-o --output)'{-o+,--output=}'[write result to specified file]:output file:_files' \ + '--random-source=[use specified file as source of random bytes]: :_files' \ + '(-r --repeat)'{-r,--repeat}'[allow output lines to repeat]' \ + '(-z --zero-terminated)'{-z,--zero-terminated}'[use NUL as line delimiter]' \ + '(-i --input-range)*: :->operands' \ + + '(excl)' \ + {-e,--echo}'[treat operands as input lines]' \ + '(:)'{-i+,--input-range=}'[treat specified numbers as input lines]:number range (x-y)' \ +&& ret=0 + +[[ $state == operands ]] && +if [[ -n ${opt_args[(i)excl-(-e|--echo)]} ]]; then + _message 'input line' && ret=0 +else + _files && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_shutdown b/Completion/Unix/Command/_shutdown index 9726182a0..a237b14e0 100644 --- a/Completion/Unix/Command/_shutdown +++ b/Completion/Unix/Command/_shutdown @@ -27,8 +27,8 @@ case $OSTYPE in '*:warning message' ) ;| - *bsd*|dragonfly*|linux*) - args=( + *bsd*|dragonfly*) + args+=( '-p[turn off power after shutdown]' ) ;| @@ -42,6 +42,11 @@ case $OSTYPE in args+=( '-o[execute halt or reboot instead of sending a signal to init]' ) + ;| + freebsd<12->.*) + args+=( + '-c[power cycle the system instead of halting if possible]' + ) ;; netbsd*) args+=( diff --git a/Completion/Unix/Command/_sqlite b/Completion/Unix/Command/_sqlite index 58f7a9116..4604fb40c 100644 --- a/Completion/Unix/Command/_sqlite +++ b/Completion/Unix/Command/_sqlite @@ -1,6 +1,6 @@ #compdef sqlite sqlite3 -local ret opt display_opt sqlite3 +local opt display_opt sqlite3 ign local -a options output_modes exclusive dashes [[ $service = sqlite3 ]] && sqlite3=true || unset sqlite3 @@ -31,16 +31,18 @@ for display_opt in $output_modes ; do options+=( "($exclusive)"$^dashes"-${opt}[set output mode to $display_opt]" ) done +(( $#words == 2 )) || ign='!' options+=( $^dashes'-separator[set output field separator]:output field separator [|]' $^dashes'-nullvalue[set text string for null values]:string' - '(- :)'$^dashes'-version[show SQLite version]' - '(- :)'$^dashes'-help[show help]' + "$ign(- :)"$^dashes'-version[show SQLite version]' + "$ign(- :)"$^dashes'-help[show help]' '1:SQLite database file:_files' - '(- :)2:SQL to run' + '(- :)2: :_guard "^-*" "SQL to run"' ) (( $+sqlite3 )) && options+=( + $^dashes'-A+[run .archive with arguments and exit]' $^dashes'-append[append the database to the end of the file]' $^dashes'-bail[stop after hitting an error]' $^dashes'-cmd[run specified command before reading stdin]:sqlite meta-command' @@ -53,6 +55,23 @@ options+=( $^dashes'-readonly[open the database read-only]' $^dashes'-stats[print memory stats before each finalize]' $^dashes'-vfs[use specified default VFS]:vfs:(unix-dotfile unix-excl unix-none unix-namedsem)' + $^dashes'-zip[open the file as a ZIP Archive]' ) +if [[ -n $words[(r)-A*] ]]; then + options=( -s -w : '(-A --A)'${^dashes}-A "(-f --file -a --append)"${(M)options:#1:*} + '(-v --verbose)'{-v,--verbose}'[print each filename as it is processed]' + '(1 -a --append -f --file)'{-f+,--file=}'[specify archive file]:archive file:_files' + '(1 -a --append -f --file)'{-a,--append=}'[operate on specified file opened using the apndvfs VFS]:archive file:_files' + '(-C --directory)'{-C+,--directory=}'[change to specified directory to read/extract files]:directory:_directories' + '(-n --dryrun)'{-n,--dryrun}'[show the SQL that would have occurred]' + '*:file:_files' + + '(commands)' \ + '(-c --create)'{-c,--create}'[create a new archive]' + '(-u --update)'{-u,--update}'[update or add files to an existing archive]' + '(-t --list)'{-t,--list}'[list contents of archive]' + '(-x --extract)'{-x,--extract}'[extract files from archive]' + ) +fi + _arguments $options diff --git a/Completion/Unix/Command/_stat b/Completion/Unix/Command/_stat new file mode 100644 index 000000000..2e84d6bf0 --- /dev/null +++ b/Completion/Unix/Command/_stat @@ -0,0 +1,96 @@ +#compdef stat gstat zstat + +# Notes: +# - @todo It would be nice to complete the -c/-f format strings some day +# - @todo It should be possible to complete NFS file handles on FreeBSD and +# Dragonfly by parsing the output of `lsof -N`, but it's not available by +# default — is there another way? + +local expl variant precmd ret=1 +local -a context line state state_descr args aopts=( -A '-*' ) +local -A opt_args + +if [[ $service == zstat ]] || [[ $precommands[-1] == builtin ]]; then + variant=zsh +else + [[ $precommands[-1] == command ]] && precmd=command + _pick_variant -c "${precmd:+$precmd }${words[1]}" -r variant \ + gnu='Free Soft' zsh='no files given' unix --version +fi + +case $OSTYPE-$variant in + *-zsh) + args=( + "(-H)-A[assign the results to array, don't print]:array variable:_parameters -g '*array*'" + - set1 + +device +inode +mode +nlink +uid +gid +rdev + +size +atime +mtime +ctime +blksize +block +link + "(-A)-H[assign the results to associative array, don't print]:associative array variable:_parameters -g '*association*'" + '(:)-f[stat the specified file descriptor]:file descriptor:_file_descriptors' + '(-s)-F[specify strftime(3) format string]: :_date_formats zsh' + '(-s)-g[show times in GMT/UTC]' + # Note that this has the *opposite* effect of other variants' -L option! + "-L[don't dereference symbolic links; use lstat(2)]" + '(-N)-n[always show names of files]' + '(-n)-N[never show names of files]' + '-o[print file modes in octal rather than decimal]' + '-r[print raw data]' + '-s[print mode, UID, GID, and times as strings]' + '(-T)-t[always show type names]' + '(-t)-T[never show type names]' + '*: :_files' + - set2 + '-l[list stat types]' + ) + ;; + *-gnu) + aopts=( ) + args=( + '*: :_files' + '(: * -)--help[display help information]' + '(: * -)--version[display version information]' + '(-L --dereference)'{-L,--dereference}'[dereference symbolic links]' + + '(d)' # Display options + {-c+,--format=}'[display per the specified format string]:format string' + {-f,--file-system}'[display file-system status instead of file status]' + '--printf=[display as with -c, but interpret backslash escapes like printf(3)]' + {-t,--terse}'[display in terse format]' + ) + ;; + darwin*|dragonfly*|*bsd*) + args=( + '*: :->files-or-handles' + '(-H)-L[dereference symbolic links]' + '-q[suppress error messages about lstat(2)/stat(2) failure]' + + '(d)' # Primary display options + '(-F)-f+[display per the specified format string]:format string' + '-l[display in `ls -lT` format]' + '(-F -t)-r[display in raw (numerical) format]' + '(-F -t)-s[display in shell variable-assignment format]' + '(-F)-x[display in verbose (Linux-style) format]' + + D # Secondary display options + '(-f -r -s -x)-F[append file type indicators (implies -l)]' + '-n[suppress terminating newlines]' + '(-r -s)-t+[specify strftime(3) format string]: :_date_formats' + ) + ;| # MATCH AGAIN + dragonfly*|freebsd*) + args+=( + + df + '(-L)-H[treat arguments as hexadecimal-formatted NFS file handles]' + ) + ;; +esac + +(( $#args )) || args=( '*: :_files' ) + +_arguments -s -S $aopts : $args && ret=0 + +[[ $state == files-or-handles ]] && +if [[ -n ${opt_args[(i)*--H]} ]]; then + _message -e nfs-handles 'NFS file handle' +else + _files && ret=0 +fi + +return ret diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index b7e10c06b..e16be7e59 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -26,7 +26,7 @@ _svn () { _arguments -C -A "-*" \ '(-)--help[print help information]' \ - '(- *)--version[print client version information]' \ + '(*)--version[print client version information]' \ '1: :->cmds' \ '*:: :->args' && ret=0 @@ -169,6 +169,9 @@ _svn () { '*:file:_files -g "(.svn|*)(/e:_svn_deletedfiles:,e:_svn_status:)"' ) ;; + (unshelve) + args+=( '1:shelf name:compadd - ${${(f)"$(_call_program shelves svn unshelve -q --list)"}%% *}' ) + ;; (*) case $usage in *(SRC|DST|TARGET|URL*PATH)*) diff --git a/Completion/Unix/Command/_tac b/Completion/Unix/Command/_tac new file mode 100644 index 000000000..7a15bffff --- /dev/null +++ b/Completion/Unix/Command/_tac @@ -0,0 +1,19 @@ +#compdef tac gtac + +local variant + +_pick_variant -r variant gnu='Free Soft' unix --version + +# NetBSD (at least) has its own bare-bones version of this tool +[[ $variant == gnu ]] || { + _default + return +} + +_arguments -s -S : \ + '(: -)--help[display help information]' \ + '(: -)--version[display version information]' \ + '(-b --before)'{-b,--before}'[attach separator before instead of after]' \ + '(-r --regex)'{-r,--regex}'[treat separator as regular expression (with -s)]' \ + '(-s --separator)'{-s+,--separator=}'[use specified separator instead of newline]:separator' \ + '*: :_files' diff --git a/Completion/Unix/Command/_tee b/Completion/Unix/Command/_tee new file mode 100644 index 000000000..66ef66e19 --- /dev/null +++ b/Completion/Unix/Command/_tee @@ -0,0 +1,32 @@ +#compdef tee gtee + +local ret=1 +local -a context line state state_descr args +local -A opt_args + +args=( + '(: -)--help[display help information]' + '(: -)--version[display version information]' + '(-a --append)'{-a,--append}'[append to files instead of overwriting]' + '(-i --ignore-interrupts)'{-i,--ignore-interrupts}'[ignore interrupt signals]' + '(--output-error)-p[warn on errors writing to non-pipes]' + '(-p)--output-error=[specify write-error behavior]: :->errmodes' +) + +# Filter out non-GNU options if applicable +_pick_variant gnu='Free Soft' unix --version || +args=( ${(@M)args:#(|*\))-[ai]\[*} ) + +_arguments -s -S : $args '*: :_files' && ret=0 + +[[ $state == errmodes ]] && { + args=( + 'exit[exit on errors writing to any output]' + 'exit-nopipe[exit on errors writing to non-pipes]' + 'warn[warn on errors writing to any output]' + 'warn-nopipe[warn on errors writing to non-pipes]' + ) + _values 'error mode' $args && ret=0 +} + +return ret diff --git a/Completion/Unix/Command/_tiff b/Completion/Unix/Command/_tiff index 588476d5a..128aeb0c0 100644 --- a/Completion/Unix/Command/_tiff +++ b/Completion/Unix/Command/_tiff @@ -14,7 +14,7 @@ if [[ $# -ne 0 || $+_in_tiff -ne 0 ]]; then set -- "$expl[@]" fi _wanted files expl 'picture file' _path_files "$@" -g "$pat" - || - _files "$@" "$expl[@]" -g '*.(#i)tiff(-.)' + _files "$@" "$expl[@]" -g '*.(#i)tif(|f)(-.)' return fi @@ -26,87 +26,143 @@ typeset -A opt_args case "$service" in tiff2bw) _arguments -C \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-r[specify rows per strip]:rows per strip' \ - '-R[specify percentage of red channel]:percentage of red channel' \ - '-G[specify percentage of green channel]:percentage of green channel' \ - '-B[specify percentage of blue channel]:percentage of blue channel' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ + '-R+[specify percentage of red channel]:percentage' \ + '-G+[specify percentage of green channel]:percentage' \ + '-B+[specify percentage of blue channel]:percentage' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; +tiff2pdf) + _arguments -s \ + '-o+[specify output file]:output file:_files -g "*.(#i)pdf(-.)"' \ + '(-z -d)-j[compress with JPEG]' \ + '(-j -d)-z[compress with Zip/Deflate]' \ + '-q+[specify compression quality]:quality' \ + '-n[no compressed data passthrough]' \ + "(-z -j)-d[don't compress]" \ + '-i[invert colors]' \ + '-u+[set distance unit]:unit:((i\:inches m\:centimeters))' \ + '-x+[set x resolution]:resolution (dots per unit)' \ + '-y+[set y resolution]:resolution (dots per unit)' \ + '-w+[specify width in units]:width' \ + '-l+[specify length in units]:length' \ + '-r+[specify scope for resolution settings]:scope:((d\:images\ without\ resolution o\:all\ images))' \ + '-p+[specify paper size]:paper size:(letter legal A4)' \ + '-F[make the tiff fill the PDF page]' \ + '-f[set PDF "Fit Window" user preference]' \ + '-e+[specify date]:date (YYYYMMDDHHMMSS)' \ + '-c+[set document creator, overrides image software default]:creator' \ + '-a+[set document author, overrides image artist default]:author' \ + '-t+[set document title, overrides image document name default]:title' \ + '-s+[set document subject, overrides image image description default]:subject' \ + '-k+[set document keywords]:keywords' \ + '-b[set PDF "Interpolate" user preference]' \ + '(- :)-h[display usage information]' \ + ':input file:_files -g "*.(#i)tif(|f)(-.)"' + ;; tiff2ps) - _arguments \ - '-1[generate PostScript Level I output]' \ - '-2[generate PostScript Level II output]' \ + _arguments -s \ + '!(-2 -3 -8 -m)-1' \ + '(-3)-2[generate PostScript Level 2 output]' \ + '(-2)-3[generate PostScript Level 3 output]' \ + '-8[disable use of ASCII85 encoding with PostScript Level 2/3]' \ '-a[generate output for all IFDs]' \ - '-d[set initial TIFF directory]:initial TIFF directory' \ - '(-p)-e[generate Encapsulated PostScript]' \ - '-o[set initial TIFF directory (file offset)]:file offset' \ + '-b+[set the bottom margin]:margin (inches)' \ + '-c[center image]' \ + '-C+[set postscript document creator name]:creator' \ + '-d+[set initial TIFF directory]:initial TIFF directory' \ + '(-e)-D[print two pages per sheet (duplex)]' \ + '(-p -D -T)-e[generate Encapsulated PostScript]' \ + '-h+[set printed page height]:height (inches)' \ + '-w+[set printed page width]:width (inches)' \ + '(-W)-H+[split image if height is more than specified value]:limit (inches)' \ + '(-H)-W+[split image if width is more than specified value]:limit (inches)' \ + '-L+[specify overlap for split images]:overlap (inches)' \ + '-i+[enable/disable (Nz/0) pixel interpolation]:state [enabled]:((0\:disable 1\:enable))' \ + '-l+[set the left margin]:margin (inches)' \ + '-m[use "imagemask" operator instead of "image"]' \ + '-o+[set initial TIFF directory (file offset)]:file offset (bytes)' \ '(-e)-p[generate non-Encapsulated PostScript]' \ - '-h[set page height]:page height' \ - '-w[set page width]:page width' \ - '-8[disable use of ASCII85 encoding]' \ - '-D[print two pages per sheet]' \ - '-O[specify output file]:output file:_files -g "*.(#i)ps(-.)"' \ + '-O+[specify output file]:output file:_files -g "*.(#i)(|e)ps(-.)"' \ + '-P+[set PageOrientation DSC comment to Landscape or Portrait]:orientation:(L P)' \ + '-r+[rotate image]:rotation:(90 180 270 auto)' \ '-s[generate output for a single image]' \ - '-T[print pages for top edge binding]' \ + '-t+[set postscript document title]:title' \ + '(-e)-T[print pages for top edge binding]' \ + '(-y)-x[override resolution units as centimeters]' \ + '(-x)-y[override resolution units as inches]' \ + '-z[enable printing in the deadzone]' \ '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffcmp) - _arguments \ + _arguments -s \ '-l[list all differing bytes]' \ + '-z+[list specified number of bytes that differs between the files]:bytes' \ '-t[ignore differences in directories]' \ ':first input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' \ ':second input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffcp) - _arguments -C \ - '-B[write output in bin-endian byte order]' \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-o[set initial TIFF directory (file offset)]:file offset' \ - '-p[set sample packing]:sample packing:(contig separate)' \ + _arguments -C -s \ + '-a[append to output instead of overwriting]' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-o+[set initial TIFF directory (file offset)]:file offset' \ + '-p+[set sample packing]:sample packing:(contig separate)' \ '(-t)-s[write output in strips]' \ '(-s)-t[write output in tiles]' \ + '-x[force the merged tiff pages in sequence]' \ + '-8[write BigTIFF instead of default ClassicTIFF]' \ + '(-L)-B[write output in big-endian byte order instead of native ordering]' \ + '(-B)-L[write output in little-endian byte order instead of native ordering]' \ + '-M[disable use of memory-mapped files]' \ + '-C[disable strip chopping]' \ '-i[ignore read errors]' \ - '-r[specify rows per strip]:rows per strip' \ - '-w[specify output tile width]:output tile width' \ - '-l[specify output tile length]:output tile length' \ - '-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \ - '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 + '-b+[specify bias (dark) monochrome image to be subtracted from all others]:file:_files' \ + '-,=-[specify substitute character for image indices]:character [,]' \ + '-r+[specify rows per strip]:rows per strip' \ + '-w+[specify output tile width]:output tile width' \ + '-l+[specify output tile length]:output tile length' \ + '-f+[specify fill order]:fill order:(lsb2msb msb2lsb)' \ + '*:TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffdither) _arguments -C \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-f[specify fill order]:fill order:(lsb2msb msb2lsb)' \ - '-r[specify rows per strip]:rows per strip' \ - '-t[set threshold for dithering]:dither threshold value' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-f+[specify fill order]:fill order:(lsb2msb msb2lsb)' \ + '-r+[specify rows per strip]:rows per strip' \ + '-t+[set threshold for dithering]:dither threshold value [128]' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffdump) _arguments \ - '-o[set initial TIFF directory (file offset)]:file offset:' \ + '-o+[set initial TIFF directory (file offset)]:file offset' \ '-h[print numbers in hexadecimal]' \ + '-m+[change number of indirect items printed]:items [24]' \ '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffinfo) - _arguments \ + _arguments -s \ '-c[display colormap and color/gray response curves]' \ '-D[read and decompress data]' \ '-d[print decompressed data]' \ '-j[display JPEG-related tags]' \ - '-o[set initial TIFF directory (file offset)]:file offset' \ + '-o+[set initial TIFF directory (file offset)]:file offset' \ + '-r[read/display raw image data instead of decoded data]' \ '-s[display offsets and byte counts for all data strips]' \ '-i[ignore read errors]' \ - '-f[force fill order]:fill order:(lsb2msb msb2lsb)' \ + '-f+[force fill order]:fill order:(lsb2msb msb2lsb)' \ '-w[display raw data in words]' \ + '-z[enable strip chopping]' \ '*:input TIFF file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; tiffmedian) _arguments -C \ - '-r[specify rows per strip]:rows per strip' \ - '-C[specify number of colormap entries]:number of colormap entries' \ - '-c[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ + '-C+[specify number of colormap entries]:number of colormap entries' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ '-f[use Floyd-Steinberg dithering]' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 @@ -117,52 +173,57 @@ tiffsplit) ':output file prefix' && ret=0 ;; fax2tiff) - _arguments \ + _arguments -s \ + '!(-1 -2 -3 -4)-'{1,3} \ '(-1 -4)-2[input is Group 3, 2d encoded]' \ - '(-2 -4)-1[input is Group 3, 1d encoded]' \ - '(-1 -2)-4[input is Group 4 encoded]' \ - '(-W)-B[0 in input is black]' \ - '(-B)-W[0 in input is white]' \ - '(-M)-L[input is lsb-to-msb]' \ - '(-L)-M[input is msb-to-lsb]' \ - '-R[specify resolution]:resolution (lines per inch)' \ - '-o[specify output file]:output file:_files -g "*.(#i)tif(|f)(-.)"' \ - '(-f)-c[generate `classic'"'"' TIFF format]' \ - '(-c)-f[generate TIFF Class F format]' \ + '(-1 -2 -A)-4[input is Group 4 encoded]' \ + '-U[input is uncompressed]' \ + '(-4)-A[input is EOL-aligned]' \ + '-B[0 in input means black]' \ + '-M[input is msb-to-lsb]' \ + '-R+[specify resolution]:resolution (lines per inch) [196]' \ + '-X+[specify input data width]:width [1728]' \ + '-o+[specify output file]:output file:_files -g "*.(#i)tif(|f)(-.)"' \ + '(-5 -p)-8[generate G4-encoded output]' \ + '-u[generate uncompressed output]' \ + '(-8)-5[generate 1d encoded output]' \ + "(-8)-p[don't align EOL codes]" \ + '-c[generate `classic'"'"' TIFF format]' \ '-m[output in msb-to-lsb order]' \ - "-p[don't align EOL codes]" \ - '-s[duplicate all rows]' \ + '-r+[specify rows per strip]:rows per strip' \ + '-s[stretch image by duplicating all rows]' \ '-v[verbose mode]' \ + '-z[generate LZW compressed output]' \ ':FAX input file:_files -g "*.(#i)(g[34]|fax)(-.)"' && ret=0 ;; gif2tiff) _arguments -C \ - '-r[specify rows per strip]:rows per strip' \ - '-c[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ ':input GIF file:_files -g "*.(#i)gif(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; ppm2tiff) _arguments -C \ - '-r[specify rows per strip]:rows per strip' \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-R[specify resolution]:resolution:' \ + '-r+[specify rows per strip]:rows per strip' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-R+[specify resolution]:resolution (dots/inch)' \ ':input GIF file:_files -g "*.(#i)ppm(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; ras2tiff) _arguments -C \ - '-r[specify rows per strip]:rows per strip' \ - '-c[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ ':input raster image file:_files -g "*.(#i)ras(|t)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; pal2rgb) _arguments -C \ - '-C[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \ - '-p[set sample packing]:sample packing:(contig separate)' \ - '-c[specify compression scheme]:compression scheme:->compress' \ - '-r[specify rows per strip]:rows per strip' \ + '-C+[specify number of bits for colormap entries]:bits for colormap entries:(8 16)' \ + '-p+[set sample packing]:sample packing:(contig separate)' \ + '-c+[specify compression scheme]:compression scheme:->compress' \ + '-r+[specify rows per strip]:rows per strip' \ ':input file:_files -g "*.(#i)tif(|f)(-.)"' \ ':output file:_files -g "*.(#i)tif(|f)(-.)"' && ret=0 ;; @@ -179,7 +240,7 @@ if [[ -n "$state" ]]; then case "$scheme" in g3) - _values -s : 'FAX Group 3 options' \ + _values -s : 'FAX Group 3 option' \ '(2d)1d[use 1D-encoding]' \ '(1d)2d[use 2D-encoding]' \ 'fill[byte-align EOL codes]' && ret=0 @@ -188,8 +249,8 @@ if [[ -n "$state" ]]; then _message -e values "compression quality (0-100), or \`r' (output RGB)" ret=0 ;; - lzw|zip) - _values 'LZW and deflate options' \ + lzw|lzma|zip) + _values 'LZW and deflate option' \ '1[without differencing]' \ '2[with differencing]' && ret=0 ;; @@ -198,8 +259,8 @@ if [[ -n "$state" ]]; then _tags values while _tags; do while _next_label values expl 'compression scheme'; do - compadd "$expl[@]" - none g4 packbits && ret=0 - compadd "$expl[@]" -qS: - lzw zip jpeg g3 && ret=0 + compadd "$expl[@]" - none jbig g4 packbits sgilog && ret=0 + compadd "$expl[@]" -qS: - lzw zip lzma jpeg g3 && ret=0 done (( ret )) || return 0 done diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux index 730959e84..ae3446a08 100644 --- a/Completion/Unix/Command/_tmux +++ b/Completion/Unix/Command/_tmux @@ -235,6 +235,7 @@ _tmux-choose-client() { _tmux-choose-tree() { [[ -n ${tmux_describe} ]] && print "put a window into tree choice mode" && return _arguments -s \ + '-G[include all sessions in any session groups in the tree rather than only the first]' \ '-N[start without the preview]' \ '-F+[specify format for each list item]:format:__tmux-formats' \ '-f+[filter items]:filter format:__tmux-formats' \ @@ -562,6 +563,8 @@ _tmux-paste-buffer() { _tmux-pipe-pane() { [[ -n ${tmux_describe} ]] && print "pipe output from a pane to a shell command" && return _arguments -s -A "-*" -S \ + '-I[write stdout from command to the pane as if it were typed]' \ + '-O[pipe output from the pane to the command (default unless -I used)]' \ '-o[only open a pipe if none is currently opened]' \ '-t+[specify target pane]:pane:__tmux-panes' \ ':shell command:_cmdstring' @@ -658,12 +661,13 @@ _tmux-save-buffer() { } _tmux-select-layout() { - [[ -n ${tmux_describe} ]] && print "choose a layout for a window" && return + [[ -n ${tmux_describe} ]] && print "choose a layout for a pane" && return _arguments -s -A "-*" -S \ + '-E[spread the current pane and any panes next to it out evenly]' \ '-n[behave like next-layout]' \ '-o[revert to previous layout]' \ '-p[behave like previous-layout]' \ - '-t+[specify a target window]:target window:__tmux-windows' \ + '-t+[specify a target pane]:target pane:__tmux-panes' \ ':layout:(even-horizontal even-vertical main-horizontal main-vertical tiled)' } diff --git a/Completion/Unix/Command/_uptime b/Completion/Unix/Command/_uptime new file mode 100644 index 000000000..58b4d991b --- /dev/null +++ b/Completion/Unix/Command/_uptime @@ -0,0 +1,26 @@ +#compdef uptime guptime + +local variant + +_pick_variant -r variant procps=procps gnu='Free Soft' unix --version + +case $variant in + procps) + _arguments -s -S : \ + '(: -)'{-h,--help}'[display help information]' \ + '(: -)'{-V,--version}'[display version information]' \ + + '(excl)' \ + {-p,--pretty}'[display uptime in pretty format]' \ + {-s,--since}'[display date/time of system boot]' + return + ;; + gnu) + _arguments -S : \ + '(: -)--help[display help information]' \ + '(: -)--version[display version information]' \ + '1:utmp/wtmp file:_files' + return + ;; + # *BSD, Darwin, Solaris, BusyBox + *) _message 'no more arguments'; return 1 ;; +esac diff --git a/Completion/Unix/Command/_user_admin b/Completion/Unix/Command/_user_admin index 7eeec7e9b..fe28c13f5 100644 --- a/Completion/Unix/Command/_user_admin +++ b/Completion/Unix/Command/_user_admin @@ -150,6 +150,7 @@ case ${service%???}:${(M)service%???}:$OSTYPE in *:*:linux*) args+=( '(-R --root)'{-R,--root=}'[specify directory to chroot into]:directory:_directories' + '(-P --prefix)'{-P,--prefix=}"[specify root directory to apply changes in but don't chroot]:directory:_directories" '(-D -U -L -p --password)'{-p+,--password=}'[specify encrypted password]:encrypted password' '(-)'{-h,--help}'[display help information]' ) diff --git a/Completion/Unix/Command/_vim b/Completion/Unix/Command/_vim index 042974338..8853fac30 100644 --- a/Completion/Unix/Command/_vim +++ b/Completion/Unix/Command/_vim @@ -41,7 +41,7 @@ arguments=( '-T[set terminal type]:::_terminals' '--not-a-term[skip warning for input/output not being a terminal]' '--ttyfail[exit if input or output is not a terminal]' - '-u[use given vimrc file instead of default .vimrc]::rc file:_files' + '-u[use given vimrc file instead of default .vimrc]:config:->config' "--noplugin[don't load plugin scripts]" '-o-[number of windows to open (default: one for each file)]::window count: ' '-O-[number of windows to vertically split open (default is one for each file)]::window count: ' @@ -71,7 +71,6 @@ arguments=( '--startuptime[write startup timing messages to given file]:log file:_files' '--socketid[run GVIM in another window]' '-i[use specified viminfo file]:viminfo file [~/.viminfo]:_files' - '--clean[defaults, no plugins, no viminfo]' '(- *)'{-h,--help}'[print help and exit]' '(- *)--version[print version information and exit]' '(* -q)-t[edit file where tag is defined]:tag:_complete_tag' @@ -90,7 +89,7 @@ arguments=( '--role[set unique role to identify main window]:role' '--socketid[open vim inside another GTK widget]:xid' '--echo-wid[echo window ID on stdout]' - '-U[use given gvimrc file instead of default .gvimrc]::rc file:_files' + '-U[use given gvimrc file instead of default .gvimrc]:gui config:->configgui' ) _arguments -C -S $arguments && ret=0 @@ -120,6 +119,23 @@ elif [[ $state = verbosity ]]; then fi (( ret )) || break done +elif [[ "$state" = config* ]]; then + _tags special files + local names=( + "NONE:'skip initialization from files and environment variables'" + "NORC:'same as NONE, but load plugins'" + ) + # gvim only supports -U NONE to skip GUI initialization. + [[ $state != configgui || $service != *g* ]] && names+=( + "DEFAULTS:'same as NONE, but loads defaults.vim'" + ) + while _tags; do + _requested special && _describe -V 'special' "(${(F)names})" && ret=0 + if _requested files expl 'rc file'; then + _files "$expl[@]" && ret=0 + fi + (( ret )) || break + done fi return ret diff --git a/Completion/Unix/Command/_vorbis b/Completion/Unix/Command/_vorbis index cb3e3f9d8..6c94469f9 100644 --- a/Completion/Unix/Command/_vorbis +++ b/Completion/Unix/Command/_vorbis @@ -1,90 +1,148 @@ -#compdef oggenc ogg123 ogginfo oggdec +#compdef oggenc ogg123 ogginfo oggdec vorbiscomment -local expl ret=1 +local curcontext="$curcontext" ret=1 +local -a alts expl state line suf case $service in oggenc) - _arguments -s \ - '(- *)'{-h,--help}'[show help]' \ - '(- *)'{-v,--version}'[display version information]' \ + _arguments -C -s -S \ + '(-Q --quiet)'{-Q,--quiet}'[produce no output to stderr]' \ + '(- *)'{-h,--help}'[display usage information]' \ + '(- *)'{-V,--version}'[display version information]' \ + '(-k --skeleton)'{-k,--skeleton}'[add an Ogg Skeleton bitstream]' \ '(-r --raw)'{-r,--raw}'[assume input data is raw, little-endian with no header information]' \ - '(-B --raw-bits)'{-B+,--raw-bits=}'[set raw mode input sample size in bits]:sample size:(8 16)' \ - '(-C --raw-chan)'{-C+,--raw-chan=}'[set raw mode input number of channels]:number of channels' \ - '(-R --raw-rate)'{-R+,--raw-rate=}'[set raw mode input sample rate]:sample rate:(44100 48000)' \ - '--raw-endianness[set raw mode endianness]:endianness:((0\:big\ endian 1\:little\ endian))' \ - '(-Q --quiet)'{-Q,--quiet}'[quiet mode]' \ + '(-B --raw-bits)'{-B+,--raw-bits=}'[set raw mode input sample size in bits]:sample size [16]:(8 16)' \ + '(-C --raw-chan)'{-C+,--raw-chan=}'[set raw mode input number of channels]:number of channels [2]' \ + '(-R --raw-rate)'{-R+,--raw-rate=}'[set raw mode input sample rate]:sample rate [44100]:(44100 48000)' \ + '--raw-endianness=[set raw mode endianness]:endianness [0]:((0\:big\ endian 1\:little\ endian))' \ '(-b --bitrate)'{-b+,--bitrate=}'[set encoding to the bitrate closest to that specified]:bitrate (kb/s)' \ + '--managed[enable the bitrate management engine]' \ '(-m --min-bitrate)'{-m+,--min-bitrate=}'[set minimum bitrate]:bitrate (kb/s)' \ '(-M --max-bitrate)'{-M+,--max-bitrate=}'[set maximum bitrate]:bitrate (kb/s)' \ - '--managed[turn off the normal VBR encoding]' \ + '*--advanced-encode-option=:option name:_values option + "lowpass_frequency[set the lowpass frequency]\:frequency (kHz)" + "impulse_noisetune[set a noise floor bias]\:bias (-15..0)" + "bitrate_hard_max[set the allowed bitrate maximum for the encoded file]\:bitrate (kb/s)" + "bitrate_hard_min[set the allowed bitrate minimum for the encoded file]\:bitrate (kb/s)" + "bit_reservoir_bits[set the total size of the bit reservoir]\:bits" + "bit_reservoir_bias[set the behavior bias of the bit reservoir]\:bias (0..1)" + "bitrate_average[set the average bitrate for the file]\:bitrate (kb/s)" + "bitrate_average_damping[set the reaction time for the average bitrate tracker]\:time (seconds)" + "disable_coupling[disable use of channel coupling for multichannel encoding]"' \ '(-q --quality)'{-q+,--quality=}'[set encoding quality]:quality:(0 1 2 3 4 5 6 7 8 9 10)' \ - '--resample[resample input to the given sample rate before encoding]:sample rate (Hz)' \ + '--resample=[resample input to the given sample rate before encoding]:sample rate (Hz)' \ '--downmix[down mix input from stereo to mono]' \ - '--advanced-encode-option:option name:_values option "bitrate_average_window[set the managed bitrate window]\:number (seconds)" "lowpass_frequency[set the lowpass frequency]\:frequency (kHz)"' \ - '(-s --serial)'{-s+,--serial=}'[force a specific serial number in the output stream]' \ + '--scale=[set input scaling factor]:scaling factor' \ + '(-s --serial)'{-s+,--serial=}'[force a specific serial number in the output stream]:serial number' \ "--discard-comments[don't copy comments from FLAC file to output Ogg Vorbis file]" \ + '--ignorelength[ignore the datalength in Wave headers]' \ '(-o --output)'{-o+,--output=}'[write the Ogg Vorbis stream to output_file]:files:->oggfiles' \ '(-n --names)'{-n+,--names=}'[specify pattern for producing filenames]:string' \ '(-X --name-remove)'{-X+,--name-remove=}'[remove specified characters from output filenames]:characters' \ '(-P --name-replace)'{-P+,--name-replace=}'[specify replacement characters for those removed]:characters' \ - '(-c --comment)'{-c+,--comment}'[add the string comment as an extra comment]:comment' \ - '(-a --artist)'{-a+,--artist}'[set the artist comment field in the comments to artist]:artist' \ - '(-G --genre)'{-G+,--genre}'[set the genre comment field in the comments to genre]:genre' \ - '(-d --date)'{-d+,--date}'[set the date comment field to the given value]:date' \ - '(-N --tracknum)'{-N+,--tracknum}'[set the track number comment field to the given value]:track number' \ - '(-t --title)'{-t+,--title}'[set the track title comment field to title]:title' \ - '(-l --album)'{-l+,--album}'[set the album comment field to album]' \ + '--utf8[interpret command-line parameters as already being UTF-8 encoded]' \ + \*{-c+,--comment=}'[add the string comment as an extra comment]:comment' \ + \*{-d+,--date=}'[set the date comment field to the given value]:date' \ + \*{-N+,--tracknum=}'[set the track number comment field to the given value]:track number' \ + \*{-t+,--title=}'[set the track title comment field to title]:title' \ + \*{-l+,--album=}'[set the album comment field to album]:album' \ + \*{-a+,--artist=}'[set the artist comment field in the comments to artist]:artist' \ + \*{-G+,--genre=}'[set the genre comment field in the comments to genre]:genre' \ + \*{-L+,--lyrics=}'[include lyrics from specified file]:lyrics file:_files -g "*.(srt|lrc)(-.)"' \ + \*{-Y+,--lyrics-language=}'[specify language for the lyrics]:language' \ '*:input file:_files -g "(#i)*.(flac|wav|aiff)(-.)"' && ret=0 ;; ogg123) - _arguments -C -s \ - '(- *)'{-h,--help}'[show help]' \ - '(- *)'{-V,--version}'[display version information]' \ - \*{-d+,--device}'[output device]:device:((null\:discard\ all\ data oss\:open\ sound\ system sun\:sun\ audio alsa\:advanced\ linux\ sound\ architecture irix\:IRIX\ audio arts\:aRts\ sound\ daemon esd\:enlightened\ sound\ daemon au\:sun\ audio\ file raw\:raw\ sample wav\:wav\ file))' \ + _arguments -C -s -S \ + \*{-d+,--device=}'[output device]:device:(aixs alsa arts au esd irix macosx nas null oss pulse raw roar sndio sun wav wmm)' \ \*{-f+,--files=}'[output filename for a previously specified file device]:output filename:_files -g "(#i)*.(wav|au|raw)(-.)"' \ - '(-k --skip)'{-k+,--skip}"[skip the first 'n' seconds (or to hh:mm:ss)]:seconds" \ - '(-K --end)'{-K+,--end}"[end at 'n' seconds (or hh:mm:ss)]:seconds" \ - '(-b --buffer)'{-b+,--buffer}'[size of input buffer]:kilobytes' \ - '(-p --prebuffer)'{-p+,--prebuffer}'[prebuffer percentage]:percent' \ - '(-q --quiet)*'{-v,--verbose}'[increase verbosity]' \ - '(-q --quiet -v --verbose)'{--quiet,-q}'[quiet mode]' \ - '(-x --nth)'{-x+,--nth}'[block decode intervall]:number' \ - '(-y --ntimes)'{-y+,--ntimes}'[block repeat count]:number' \ - '(-z --shuffle)'{-z,--shuffle}'[shuffle play]' \ - '(-l --delay)'{-l+,--delay=}'[set delay between two SIGINTs to quit]:delay (ms)' \ - '(-@ --list)'{-@+,--list}'[play all of the files from a playlist]:playlist:_files' \ - '--audio-buffer=[size of output audio buffer]:kilobytes' \ + '--audio-buffer=[specify size of output audio buffer]:size (kilobytes)' \ \*{-o,--device-option=}'[assign device option values]:device option:->devopts' \ - '*:sound file or directory:_files -g "(#i)*.(ogg|flac|spx)"' && ret=0 + '(-@ --list)'{-@+,--list=}'[play all of the files from a playlist]:playlist:_files' \ + '(-r --repeat)'{-r,--repeat}'[repeat playlist indefinitely]' \ + '(-R --remote)'{-R,--remote}'[use remote control interface]' \ + '(-z --shuffle -Z --random)'{-z,--shuffle}'[shuffle list of files before playing]' \ + '(-Z --random -z --shuffle -r --repeat)'{-Z,--random}'[play files randomly until interrupted]' \ + '(-b --buffer)'{-b+,--buffer=}'[specify size of input buffer (HTTP only)]:size (kilobytes)' \ + '(-p --prebuffer)'{-p+,--prebuffer=}'[delay playback until proportion of buffer filled (HTTP only)]:percent' \ + '(-k --skip)'{-k+,--skip=}"[skip up to specified time]:start time ([[hh\:]mm\:]ss[.d])" \ + '(-K --end)'{-K+,--end=}"[end after specified time]:end time ([[hh\:]mm\:]ss[.d])" \ + '(-x --nth)'{-x+,--nth=}"[play every 'n'th block]:number"\ + '(-y --ntimes)'{-y+,--ntimes=}"[repeat every 'n'th block]:number" \ + '(-l --delay)'{-l+,--delay=}'[set delay between two SIGINTs to quit]:delay (ms)' \ + '(- *)'{-h,--help}'[display usage information]' \ + '(-q --quiet -v --verbose)'{--quiet,-q}'[quiet mode]' \ + '(-q --quiet)*'{-v,--verbose}'[increase verbosity]' \ + '(- *)'{-V,--version}'[display version information]' \ + \*{-c-,--config=-}'[specify config options]: :_values option + "default_device\:device" + "shuffle\:value\:(0 1)" + "repeat\:value\:(0 1)"' \ + '*:sound file or directory:->urls-or-files' && ret=0 ;; ogginfo) - _arguments \ - '(- *)-h[show a help and usage message]' \ + _arguments -S \ + '(- *)-h[display usage information]' \ + '(- *)-V[display version information]' \ '(-)*-q[quiet mode]' \ '(-)-v[verbose mode]' \ - '*:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' && ret=0 + '(-h)*:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' && ret=0 ;; oggdec) - _arguments -s \ + _arguments -s -S \ '(-Q --quiet)'{-Q,--quiet}'[quiet mode]' \ - '(- *)'{-h,--help}'[print help information]' \ - '(- *)'{-v,--version}'[display version information]' \ + '(- *)'{-h,--help}'[display usage information]' \ + '(- *)'{-V,--version}'[display version information]' \ '(-b --bits)'{-b+,--bits=}'[bits per sample]:bits per sample:(8 16)' \ - '(-e --endian)'{-e+,--endian=}'[set endianness for 16-bit output]:endianness:((0\:\(default\)\ little-endian\ \(Intel\ byte\ order\) 1\:big-endian\ \(sane\ byte\ order\)))' \ - '(-R --raw)'{-R+,--raw=}'[output in raw format]' \ + '(-e --endianness)'{-e+,--endianness=}'[set endianness for 16-bit output]:endianness [0]:((0\:little-endian\ \(Intel\ byte\ order\) 1\:big-endian\ \(sane\ byte\ order\)))' \ + '(-s --sign)'{-s+,--sign=}'[set signedness for output]:signedness [1]:((0\:unsigned 1\:signed))' \ + '(-R --raw)'{-R,--raw}'[output in raw format]' \ '(-o --output)'{-o+,--output=}'[write output to specified filename]:output filename:_files' \ - '(-s --sign)'{-s+,--sign=}'[set signedness for output]:signedness:((0\:unsigned 1\:signed\ \(default\)))' \ '*:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' && ret=0 ;; + vorbiscomment) + _arguments -s -S \ + '(-l --list)*'{-t+,--tag=}'[specify a comment tag on the commandline]:tag=value' \ + '(-c --commentfile)'{-c+,--commentfile=}'[specify comment file]:file:_files' \ + '(-R --raw)'{-R,--raw}'[read and write comments in UTF-8]' \ + '(-e --escapes)'{-e,--escapes}'[use \\n-style escapes to allow multiline comments]' \ + '1:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' \ + '(-l --list)2:ogg vorbis file:_files -g "(#i)*.ogg(-.)"' \ + + '(actions)' \ + '(2 -t --tag)'{-l,--list}'[list the comments (default)]' \ + {-a,--append}'[append comments]' \ + {-w,--write}'[write comments, replacing the existing ones]' \ + '(-)'{-h,--help}'[display usage information]' \ + '(-)'{-V,--version}'[display version information]' && ret=0 + ;; esac -if [[ $state = devopts ]]; then - if compset -P '*:'; then - _message -e value value - else - _wanted devopts expl 'device option' \ - compadd -S : - dsp dev card buf_size host byteorder && return - fi +if [[ -n $state ]]; then + case $state in + urls-or-files) + if [[ -prefix 1 (f|ht)tp(|s):// ]]; then + alts=( 'urls:URL of sound file:_urls -f -g "*.(#i)(ogg|flax|spx)(-.)"' ) + else + alts=( 'urls:URL of sound file:compadd -S "" ftp:// http:// https://' ) + fi + _alternative \ + 'files:sound file or directory:_files -g "(#i)*.(ogg|flac|spx)"' \ + $alts && ret=0 + ;; + devopts) + if compset -P 1 '*:'; then + _message -e value value + else + _description device-options expl 'device option' + if ! compset -S ':*'; then + compadd "$expl[@]" - debug verbose quiet && ret=0 + suf=( -qS : ) + fi + compadd $suf "$expl[@]" - matrix dev buffer_time period_time use_mmap \ + multi host buf_size dsp server sink byteorder id && ret=0 + fi + ;; + esac fi return ret diff --git a/Completion/Unix/Command/_vorbiscomment b/Completion/Unix/Command/_vorbiscomment deleted file mode 100644 index bd7459e04..000000000 --- a/Completion/Unix/Command/_vorbiscomment +++ /dev/null @@ -1,18 +0,0 @@ -#compdef vorbiscomment - -#Written by Jesse Weinstein <jessw@netwood.net>, Wed Jul 19 15:31:11 2006 -#Version 0.9 - could handle -t option slightly better -#Released under the MIT license (or any compatible free-content license) -#i.e. do whatever you like with it, but credit me. - -_arguments \ - '-h[help]' \ - '-q[quiet]' \ - '(-a -w -q -c -t 2)-l[list comments]' \ - '(-l)-a[append comments]' \ - '(-l)-w[overwrite comments]' \ - '(-l -c)-t[tag and value]:: ' \ - '(-l -t)-c[tag file]::_files' \ - '1:OGG file:_files -g "*.ogg(-.)"' \ - '(-l)2:output OGG file:_files -g "*.ogg(-.)"' \ - && return 0 diff --git a/Completion/Unix/Command/_vpnc b/Completion/Unix/Command/_vpnc new file mode 100644 index 000000000..9c4f4d41b --- /dev/null +++ b/Completion/Unix/Command/_vpnc @@ -0,0 +1,54 @@ +#compdef vpnc vpnc-connect + +local ign + +(( $#words > 2 )) && ign='!' +_arguments \ + "${ign}(- : *)--version[display version information]" \ + "${ign}(- : *)--"{,long-}'help[display usage information]' \ + '--gateway=[specify IP/name of IPSec gateway]: :_hosts' \ + '--id=[specify group name]: :_groups' \ + '--username=[specify username]: :_users' \ + '--domain=[specify domain name for authentication]: :_domains' \ + '--xauth-inter[enable interactive extended authentication]' \ + '--vendor=[specify IPSec gateway vendor]:vendor:(cisco netscreen)' \ + '--natt-mode=[specify NAT-Traversal method to use]:NAT-traversal method [natt]:(( + natt\:NAT-T\ as\ defined\ in\ RFC3947 + none\:disable\ use\ of\ any\ NAT-T\ method + force-natt\:always\ use\ NAT-T\ encapsulation\ even\ without\ presence\ of\ a\ NAT\ device + cisco-udp\:Cisco\ proprietary\ UDP\ encapsulation,\ commonly\ over\ port\ 10000 + ))' \ + '--script=[specify command executed using system() to configure the interface, routing and so on]: : _command_names -e' \ + '--dh=[specify the IKE DH group]:group:(dh1 dh2 dh5)' \ + '--pfs=[specify Diffie-Hellman group to use for PFS]:group:(nopfs dh1 dh2 dh5 server)' \ + '--enable-1des[enable weak single DES encryption]' \ + '--enable-no-encryption[use no encryption for data traffic (key exchange still encrypted)]' \ + '--application-version=[specify application version to report]:application version' \ + '--ifname=[specify visible name of the TUN/TAP interface]:interface name' \ + '--ifmode=[specify mode of TUN/TAP interface]:mode [tun]:(tun tap)' \ + '--ifmtu=[set MTU for TUN/TAP device]:MTU (0-65535) [0 - automatic]' \ + "--debug[show verbose debug messages]:debug information:(( + 0\:don\'t\ print\ debug\ information + 1\:print\ minimal\ debug\ information + 2\:show\ state\ machine\ and\ packet/payload\ type\ information + 3\:dump\ everything\ excluding\ authentication\ data + 99\:dump\ everything\ including\ authentication\ data\ \(e.g.\ passwords\) + ))" \ + "--no-detach[don't detach from the console after login]" \ + '--pid-file=[store the pid of background process in specified file]:pid file:_files' \ + '--local-addr=[specify local IP to use for ISAKMP/ESP/...]: :_hosts' \ + '--local-port=[specify local ISAKMP port number to use]:ISAKMP port number (0-65535) [500]' \ + '--udp-port=[specify local UDP port number to use]:udp port (0-65535) [10000]' \ + '--dpd-idle=[send DPD packet after not receiving anything for specified time]:timeout (seconds) [600]' \ + "--non-inter[don't ask anything, exit on missing options]" \ + '--auth-mode=[specify authentication mode]:authentication mode [psk]:(( + psk\:pre-shared\ key + cert\:server\ +\ client\ certificate + hybrid\:server\ certificate\ +\ xauth + ))' \ + '--ca-file=[specify CA-PEM-File]:CA-PEM file:_files -g "*.pem(-.)"' \ + '--ca-dir=[specify trusted CA-Directory]:CA directory:_files -/' \ + '--target-network=[specify target network]:network/netmask' \ + '--password-helper=[specify password helper executable]: : _command_names -e' \ + '--print-config[print configuration in form that can be used as vpnc.conf]' \ + '*:configuration [default]:compadd - /etc/vpnc/*.conf(N:t:r)' diff --git a/Completion/Unix/Command/_webbrowser b/Completion/Unix/Command/_webbrowser index 4192aff54..e4f5fe092 100644 --- a/Completion/Unix/Command/_webbrowser +++ b/Completion/Unix/Command/_webbrowser @@ -1,3 +1,3 @@ #compdef amaya arena chimera dillo dwb express galeon grail gzilla hotjava konqueror light mmm Mosaic netrik opera opera-next retawq skipstone www xmosaic zen -_alternative 'files:file:_files' 'urls:URL:_urls' +_alternative 'files: :_files' 'urls: :_urls' diff --git a/Completion/Unix/Command/_wget b/Completion/Unix/Command/_wget index 1a7e2d0a3..2a4e722d8 100644 --- a/Completion/Unix/Command/_wget +++ b/Completion/Unix/Command/_wget @@ -22,6 +22,7 @@ _arguments -C -s \ '(--config)--no-config' '--rejected-log=:file:_files' \ '(--tries -t)'{--tries=,-t+}'[set number of retries]:number of retries' \ '--retry-connrefused[retry even if connection is refused]' \ + '--retry-on-http-error=[specify list of HTTP errors to retry]:http error' \ '(--output-document -O)'{--output-document=,-O+}'[specify file to write documents to]:output file:_files' \ '(--continue -c)'{--continue,-c}'[continue getting an existing file]' \ '--start-pos=:offset' '--show-progress' \ @@ -38,8 +39,7 @@ _arguments -C -s \ '(--wait -w)'{--wait=,-w+}'[specify wait between retrievals]:time (seconds)' \ '(--random-wait)--waitretry=:time (seconds)' \ '(--waitretry)--random-wait[random wait time between retrievals]' \ - '(--proxy -Y --no-proxy)'{--proxy=,-Y+}'[explicitly turn on proxy]' \ - '(--proxy -Y --no-proxy)--no-proxy[explicitly turn off proxy]' \ + '--no-proxy[explicitly turn off proxy]' \ '(--quota -Q)'{--quota=,-Q+}'[set retrieval quota]:number' \ '--bind-address=[specify address to bind to (hostname or IP)]:bind address:_bind_addresses' \ '--limit-rate=[specify limit to download rate]:download rate limit' \ @@ -48,7 +48,7 @@ _arguments -C -s \ '--ignore-case[ignore case when matching files/directories]' \ '(-4 --inet4-only -6 --inet6-only)'{-4,--inet4-only}'[connect only to IPv4 addresses]' \ '(-4 --inet4-only -6 --inet6-only)'{-6,--inet6-only}'[connect only to IPv6 addresses]' \ - '--prefer-family[connect first to addresses of specified family]:address family:(IPv6 IPv4 none)' \ + '--prefer-family=[connect first to addresses of specified family]:address family:(IPv6 IPv4 none)' \ '(--http-user --ftp-user)--user[set both ftp and http user]:user' \ '(--http-password --ftp-password)--password[set both ftp and http password]:password' \ '(--password --http-password --ftp-password)--ask-password:[prompt for passwords]' \ @@ -67,7 +67,7 @@ _arguments -C -s \ '(--user)--http-user=:user' \ '(--password --ask-password)--http-password=:password' \ '--no-cache[disallow server-cached data]' \ - '--default-page=[specify default page name, normally index.html]' \ + '--default-page=[specify default page name, normally index.html]:default page [index.html]' \ '(--adjust-extension -E)'{--adjust-extension,-E}'[save all HTML/CSS documents with proper extensions]' \ "--ignore-length[ignore \`Content-Length' header field]" \ '*--header=[send a custom HTTP header]:header:->header' \ @@ -93,7 +93,7 @@ _arguments -C -s \ "--auth-no-challenge[send basic HTTP authentication without first waiting for server's challenge]" \ '--secure-protocol=[choose secure protocol]:protocol:(SSLv2 SSLv3 TLSv1 TLSv1_1 TLSv1_2 PFS)' \ --https-only \ - "--no-check-certificate=[don't check the server certificate]" \ + "--no-check-certificate[don't check the server certificate]" \ '--certificate=[specify client certificate]:client certificate file:_files' \ '--certificate-type=[specify client certificate type]:certificate type:(PEM DER)' \ '--private-key=[specify private key file]:key file:_files' \ @@ -104,6 +104,7 @@ _arguments -C -s \ '--pinnedpubkey=:file:_files' \ '--random-file[specify file with random data for seeding generator]:file:_files' \ '--egd-file=[specify filename of EGD socket]:file:_files' \ + '--ciphers=[set the priority string (GnuTLS) or cipher list string (OpenSSL) directly]:string' \ '--no-hsts[disable HSTS]' \ '--hsts-file[specify path of HSTS database]:file:_files' \ '(--user)--ftp-user=:user' \ diff --git a/Completion/Unix/Command/_xxd b/Completion/Unix/Command/_xxd index 1b1613a64..0034be519 100644 --- a/Completion/Unix/Command/_xxd +++ b/Completion/Unix/Command/_xxd @@ -26,7 +26,7 @@ arguments=( '( -E -EBCDIC -i -include -p -postscript -plain -ps -r -revert )'{-E,-EBCDIC}'[print human-readable part in EBCDIC rather than ASCII]' '(-i -include -p -postscript -plain -ps -r -revert)'{-e,-endian}'[little-endian dump]' '(-b -bits -E -EBCDIC -i -include -p -postscript -plain -ps -r -revert )'{-i,-include}'[output in C include file style]' - '(-b -bits -E -EBCDIC -i -include -p -postscript -plain -ps )'{-p,-postscript,-plain,-ps}'[read or write a plain hexdump (no line numbers or ASCII rendering)]' + '(-b -bits -E -EBCDIC -i -include -p -postscript -plain -ps -C -capitalize )'{-p,-postscript,-plain,-ps}'[read or write a plain hexdump (no line numbers or ASCII rendering)]' '(-b -bits -E -EBCDIC -i -include -r -revert -u -uppercase)'{-r,-revert}'[reverse mode\: read a hex dump and output binary data]' '(-b -bits -r -revert -u -uppercase)'{-u,-uppercase}'[output upper-case hex digits]' @@ -34,7 +34,7 @@ arguments=( '(- :)'{-h,-help}'[display usage message]' '(- :)'{-v,-version}'[show program version]' '*'{-a,-autoskip}"[a single '*' replaces runs of NUL (toggleable)]" - + '(-C -capitalize)'{-C,-capitalize}'[capitalize variable names in C include file style]' {-c+,-cols}'[specify number of octets per line]: :_guard "[0-9a-fA-Fx]#" "number of octets per line"' {-g+,-groupsize}'[specify the number of octets per group]: :_guard "[0-9]#" "number of octets per group"' {-l+,-len}'[specify number of octets to output]: :_guard "[0-9]#" "number of octets to output"' |