diff options
Diffstat (limited to 'Completion')
191 files changed, 3547 insertions, 2571 deletions
diff --git a/Completion/BSD/Command/_kld b/Completion/BSD/Command/_kld index b967f33c4..34f26f1e9 100644 --- a/Completion/BSD/Command/_kld +++ b/Completion/BSD/Command/_kld @@ -4,7 +4,7 @@ _kld_module() { local ret=1 - compadd "$@" - /boot/kernel/*.ko(-.:t) /modules/*.ko(-.:t) && ret=0 + compadd "$@" - /boot/{kernel,modules}/*.ko(-.:t) && ret=0 _files "$@" -g '*.ko(-.)' && ret=0 return ret diff --git a/Completion/BSD/Command/_mixerctl b/Completion/BSD/Command/_mixerctl new file mode 100644 index 000000000..a43aed4cb --- /dev/null +++ b/Completion/BSD/Command/_mixerctl @@ -0,0 +1,11 @@ +#compdef mixerctl + +: ${(A)_cache_mixerctlvars:=${${(f)"$(mixerctl -a)"}%%=*}} +_arguments -s -S -A "-*" \ + '(-q -t *)-a[Print all device variables and their current values]' \ + '-f[Specify an alternative audio mixing device]:file:_files -g "*(-%c)"' \ + '(-q -t)-n[Suppress printing of the variable name]' \ + '(-a -n -v)-q[Suppress all printing when setting a variable]' \ + '(-a -n -v)-t[Attempt to select the next possible value of an enum]' \ + '(-q -t)-v[Show all possible values of variables]' \ + '(-a)*:mixerctl varible:_multi_parts -i -S = -q . _cache_mixerctlvars' diff --git a/Completion/BSD/Command/_portsnap b/Completion/BSD/Command/_portsnap index db71fbc60..0803a842e 100644 --- a/Completion/BSD/Command/_portsnap +++ b/Completion/BSD/Command/_portsnap @@ -1,6 +1,6 @@ #compdef portsnap -local context state line +local curcontext="$curcontext" state line typeset -A opt_args flags=( diff --git a/Completion/BSD/Type/_jails b/Completion/BSD/Type/_jails new file mode 100644 index 000000000..36bffeceb --- /dev/null +++ b/Completion/BSD/Type/_jails @@ -0,0 +1,5 @@ +#autoload + +jails=( ${${${${(f)"$(_call_program jails jls -n)"}##*jid=}/ name=/:}%% *} ) + +_describe -t jails jail jails "$@" diff --git a/Completion/Base/Completer/_expand b/Completion/Base/Completer/_expand index e52144cb7..3c76e1328 100644 --- a/Completion/Base/Completer/_expand +++ b/Completion/Base/Completer/_expand @@ -87,7 +87,7 @@ if [[ "$force" = *s* ]] || setopt aliases eval 'exp=( ${${(e)exp//\\[ -]/ }//(#b)([ +]/ }//(#b)([ \\ ])/\\$match[1]} )' 2>/dev/null setopt NO_aliases else diff --git a/Completion/Base/Completer/_external_pwds b/Completion/Base/Completer/_external_pwds new file mode 100644 index 000000000..4ad50f02b --- /dev/null +++ b/Completion/Base/Completer/_external_pwds @@ -0,0 +1,39 @@ +#autoload + +# Completes current directories of other zsh processes +# this is intended to be used via _generic bound to a +# different key. Note that pattern matching is enabled. + +local -a expl +local -au dirs + +# undo work _main_complete did to remove the tilde +PREFIX="$IPREFIX$PREFIX" +IPREFIX= +SUFFIX="$SUFFIX$ISUFFIX" +ISUFFIX= + +[[ -o magicequalsubst ]] && compset -P '*=' + +case $OSTYPE in + solaris*) + dirs=( + ${(M)${${(f)"$(pgrep -U $UID -x zsh|xargs pwdx 2>/dev/null)"}:#$$:*}%%/*} + ) + ;; + linux*) + dirs=( /proc/${^$(pidof zsh):#$$}/cwd(N:A) ) + dirs=( $^dirs(N^@) ) + ;; + *) + if (( $+commands[lsof] )); then + dirs=( ${${${(M)${(f)"$(lsof -a -u $EUID -c zsh -p \^$$ -d cwd -F n -w + 2>/dev/null)"}:#n*}#?}%% \(*} ) + fi + ;; +esac +dirs=( ${(D)dirs} ) + +compstate[pattern_match]='*' +_wanted directories expl 'current directory from other shell' \ + compadd -M "r:|/=* r:|=*" -f -a dirs diff --git a/Completion/Base/Completer/_history b/Completion/Base/Completer/_history index 63878ac1c..cd69ca17b 100644 --- a/Completion/Base/Completer/_history +++ b/Completion/Base/Completer/_history @@ -51,9 +51,14 @@ ISUFFIX= # We skip the first element of historywords so the current word doesn't # interfere with the completion +local -a hslice while [[ $compstate[nmatches] -eq 0 && beg -lt max ]]; do + if [[ -n $compstate[quote] ]] + then hslice=( ${(Q)historywords[beg,beg+slice]} ) + else hslice=( ${historywords[beg,beg+slice]} ) + fi _wanted "$opt" history-words expl 'history word' \ - compadd -Q -a 'historywords[beg,beg+slice]' + compadd -Q -a hslice (( beg+=slice )) done diff --git a/Completion/Base/Core/_main_complete b/Completion/Base/Core/_main_complete index e881ea6a1..977ab49ee 100644 --- a/Completion/Base/Core/_main_complete +++ b/Completion/Base/Core/_main_complete @@ -43,6 +43,8 @@ local -a precommands typeset -U _lastdescr _comp_ignore _comp_colors +{ + [[ -z "$curcontext" ]] && curcontext=::: zstyle -s ":completion:${curcontext}:" insert-tab tmp || tmp=yes @@ -66,6 +68,16 @@ if [[ "$compstate[insert]" = tab* ]]; then compstate[insert]="${compstate[insert]//tab /}" fi +# Second attempt at GLOB_COMPLETE + +if [[ "$compstate[pattern_match]" = "*" && + "$_lastcomp[unambiguous]" = "$PREFIX" && + -n "$_lastcomp[unambiguous_cursor]" ]]; then + integer upos="$_lastcomp[unambiguous_cursor]" + SUFFIX="$PREFIX[upos,-1]$SUFFIX" + PREFIX="$PREFIX[1,upos-1]" +fi + # Special completion contexts after `~' and `='. if [[ -z "$compstate[quote]" ]]; then @@ -128,8 +140,11 @@ _completer_num=1 # We assume localtraps to be in effect here ... integer SECONDS=0 -trap 'zle -M "Killed by signal in ${funcstack[0]} after ${SECONDS}s"; - zle -R; return 130' INT QUIT +TRAPINT TRAPQUIT() { + zle -M "Killed by signal in ${funcstack[2]} after ${SECONDS}s"; + zle -R + return 130 +} # Call the pre-functions. @@ -346,17 +361,20 @@ fi ( "$_comp_force_list" = ?* && nm -ge _comp_force_list ) ]] && compstate[list]="${compstate[list]//messages} force" -if [[ "$compstate[old_list]" = keep ]]; then - if [[ $_saved_colors_set = 1 ]]; then - ZLS_COLORS="$_saved_colors" +} always { + # Stuff we always do to clean up. + if [[ "$compstate[old_list]" = keep ]]; then + if [[ $_saved_colors_set = 1 ]]; then + ZLS_COLORS="$_saved_colors" + else + unset ZLS_COLORS + fi + elif (( $#_comp_colors )); then + ZLS_COLORS="${(j.:.)_comp_colors}" else unset ZLS_COLORS fi -elif (( $#_comp_colors )); then - ZLS_COLORS="${(j.:.)_comp_colors}" -else - unset ZLS_COLORS -fi +} # Now call the post-functions. diff --git a/Completion/Base/Utility/_arguments b/Completion/Base/Utility/_arguments index d70c44259..1f35e8d43 100644 --- a/Completion/Base/Utility/_arguments +++ b/Completion/Base/Utility/_arguments @@ -26,7 +26,7 @@ if (( long )); then if (( ! ${(P)+name} )); then local iopts sopts pattern tmpo dir cur cache - typeset -U lopts + typeset -Ua lopts cache=() diff --git a/Completion/Base/Utility/_call_program b/Completion/Base/Utility/_call_program index b65764827..010e09476 100644 --- a/Completion/Base/Utility/_call_program +++ b/Completion/Base/Utility/_call_program @@ -2,8 +2,8 @@ local tmp err_fd=-1 -if (( ${debug_fd:--1} > 2 )) -then exec {err_fd}>&2 # debug_fd is saved stderr, 2 is log file +if (( ${debug_fd:--1} > 2 )) || [[ ! -t 2 ]] +then exec {err_fd}>&2 # debug_fd is saved stderr, 2 is trace or redirect else exec {err_fd}>/dev/null fi diff --git a/Completion/Base/Utility/_describe b/Completion/Base/Utility/_describe index 1a9f52f5d..ab7200517 100644 --- a/Completion/Base/Utility/_describe +++ b/Completion/Base/Utility/_describe @@ -6,23 +6,28 @@ local _opt _expl _tmpm _tmpd _mlen _noprefix local _type=values _descr _ret=1 _showd _nm _hide _args _grp _sep local csl="$compstate[list]" csl2 local _oargv _argv _new _strs _mats _opts _i _try=0 +local OPTIND OPTARG +local -a _jvx12 # Get the option. -if [[ "$1" = -o ]]; then - _type=options - shift -elif [[ "$1" = -O ]]; then - _type=options - _noprefix=1 - shift -elif [[ "$1" = -t ]]; then - _type="$2" - shift 2 -elif [[ "$1" = -t* ]]; then - _type="${1[3,-1]}" - shift -fi +while getopts "oOt:12JVx" _opt; do + case $_opt in + (o) + _type=options;; + (O) + _type=options + _noprefix=1 + ;; + (t) + _type="$OPTARG" + ;; + (1|2|J|V|x) + _jvx12+=(-$_opt) + esac +done +shift $(( OPTIND - 1 )) +unset _opt [[ "$_type$_noprefix" = options && ! -prefix [-+]* ]] && \ zstyle -T ":completion:${curcontext}:options" prefix-needed && @@ -53,7 +58,7 @@ fi _tags "$_type" while _tags; do - while _next_label "$_type" _expl "$_descr"; do + while _next_label $_jvx12 "$_type" _expl "$_descr"; do if (( $#_grp )); then diff --git a/Completion/Base/Utility/_sequence b/Completion/Base/Utility/_sequence index 391e5f78f..f52955f46 100644 --- a/Completion/Base/Utility/_sequence +++ b/Completion/Base/Utility/_sequence @@ -7,11 +7,11 @@ # -s sep : specify separator [defaults to comma] # -d : duplicate values allowed -local curcontext="$curcontext" nm="$compstate[nmatches]" pre nosep minus +local curcontext="$curcontext" nm="$compstate[nmatches]" pre qsep nosep minus local -a sep num pref suf end uniq dedup zparseopts -D -a opts s:=sep n:=num p:=pref i:=pref P:=pref I:=suf S:=suf q=suf r:=suf R:=suf C:=cont d=uniq M: J: X: x: -(( $#cont )) && curcontext="$curcontext%:*}:$cont[2]" +(( $#cont )) && curcontext="${curcontext%:*}:$cont[2]" (( $#sep )) || sep[2]=, if (( $+suf[(r)-S] )); then @@ -19,20 +19,20 @@ if (( $+suf[(r)-S] )); then (( $#end )) && compset -S ${end}\* && suf=() && nosep=1 fi +qsep="${sep[2]}" +compquote -p qsep if (( ! $#uniq )); then (( $+pref[(r)-P] )) && pre="${(q)pref[pref[(i)-P]+1]}" - typeset -T unique="${PREFIX#$pre}" uniq $sep[2] - dedup=( ${(q)uniq[1,-2]} ) - unique="${SUFFIX}" - dedup+=( ${(q)uniq[2,-1]} ) + dedup=( "${(@)${(@ps.$qsep.)PREFIX#$pre}[1,-2]}" "${(@)${(@ps.$qsep.)SUFFIX}[2,-1]}" ) + [[ -n $compstate[quoting] ]] || dedup=( ${(Q)dedup} ) fi -if (( ! $#num )) || (( num[2] > 1 )) && ! compset -P $(( num[2] - 1 )) \*$sep[2]; then - (( nosep )) || suf=( -S $sep[2] -r "$end[1]${sep[2][1]} \t\n\-" ) - compset -S ${sep[2]}\* && suf=() - compset -P \*$sep[2] && pref=() -else +if (( $#num )) && compset -P $(( num[2] - 1 )) \*${(q)qsep}; then pref=() +else + (( ! nosep && (!$#num || num[2] > 1) )) && suf=( -S ${qsep} -r "$end[1]${(q)qsep[1]} \t\n\-" ) + compset -S ${(q)qsep}\* && suf=() + compset -P \*${(q)qsep} && pref=() fi (( minus = argv[(ib:2:)-] )) diff --git a/Completion/Base/Utility/_store_cache b/Completion/Base/Utility/_store_cache index 86e72e9a9..8feaee6f7 100644 --- a/Completion/Base/Utility/_store_cache +++ b/Completion/Base/Utility/_store_cache @@ -46,8 +46,15 @@ if zstyle -t ":completion:${curcontext}:" use-cache; then for var; do case ${(Pt)var} in (*readonly*) ;; - (*(association|array)*) print -r "$var=( ${(kv@Pqq)^^var} )";; - (*) print -r "$var=${(Pqq)^^var}";; + (*(association|array)*) + # Dump the array as a here-document to reduce parsing overhead + # when reloading the cache with "source" from _retrieve_cache + print -r "$var=( "'"${(zQ)$(<<\EO:'"$var" + print -r "${(kv@Pqq)^^var}" + print -r "EO:$var" + print -r ')}" )' + ;; + (*) print -r "$var=${(Pqq)^^var}";; esac done >! "$_cache_dir/$_cache_ident" else diff --git a/Completion/Base/Widget/_complete_debug b/Completion/Base/Widget/_complete_debug index 604486376..85a0f372a 100644 --- a/Completion/Base/Widget/_complete_debug +++ b/Completion/Base/Widget/_complete_debug @@ -9,6 +9,8 @@ local pager w="${(qq)words}" integer debug_fd=-1 { if [[ -t 2 ]]; then + zmodload -F zsh/files b:zf_ln 2>/dev/null && + zf_ln -fn =(<<<'') $tmp && exec {debug_fd}>&2 2>| $tmp fi diff --git a/Completion/Darwin/Command/_defaults b/Completion/Darwin/Command/_defaults index 7818e0379..ca5d87e65 100644 --- a/Completion/Darwin/Command/_defaults +++ b/Completion/Darwin/Command/_defaults @@ -25,8 +25,9 @@ _defaults(){ _1st_arguments=( read read-type write rename delete domains find help ) local curcontext="$curcontext" state line expl + typeset -A opt_args - _arguments -A '-*' \ + _arguments -C -A '-*' \ '(-currentHost)-host:host:_hosts' \ '(-host)-currentHost' \ '*::command:->subcmd' && return 0 diff --git a/Completion/Darwin/Command/_fink b/Completion/Darwin/Command/_fink index 55c9e8da5..04a067ec1 100644 --- a/Completion/Darwin/Command/_fink +++ b/Completion/Darwin/Command/_fink @@ -86,7 +86,7 @@ _fink(){ 'cleanup:removes obsolete package files' ) - local context state line expl + local curcontext="$curcontext" state line expl local -A opt_args _arguments \ @@ -136,8 +136,8 @@ _fink(){ '(-t --tab)'{-t,--tab}'[output the list with tabs as field delimiter]' \ '(-w --width)'{-w=,--width=}'[width of display]:number or "auto"' \ '(1 : -)'{-h,--help}'[display help text]' \ - '1: :->pkgs' && return 0 - + '1: :->pkgs' && return + if [[ "$state" == pkgs ]]; then _fink_get_packages _wanted packages expl 'package hint' compadd -a packages @@ -161,6 +161,7 @@ _fink(){ #scanpackages) #checksums) #cleanup) + *) _default ;; esac } diff --git a/Completion/Debian/Command/_apt b/Completion/Debian/Command/_apt index bf5343a94..db4ceef10 100644 --- a/Completion/Debian/Command/_apt +++ b/Completion/Debian/Command/_apt @@ -455,6 +455,7 @@ _apt-get () { --tar-only:bool \ --arch-only:bool \ --allow-unauthenticated:bool \ + --auto-remove:bool \ -- \ /$'update\0'/ \| \ /$'upgrade\0'/ \| \ diff --git a/Completion/Debian/Command/_apt-file b/Completion/Debian/Command/_apt-file index eddbbdcf5..98a93fdd3 100644 --- a/Completion/Debian/Command/_apt-file +++ b/Completion/Debian/Command/_apt-file @@ -1,55 +1,59 @@ #compdef apt-file -_apt-file() { - local -a arguments - local state line cmds - arguments=( - '(--cache -c)'{--cache,-c}'[cache directory]:directory:_directories' - '(-v --verbose)'{-v,--verbose}'[verbose]' - '(--cdrom-mount -d)'{--cdrom-mount,-d}'[cdrom mount point]:directory:_directories' - '(--ignore-case -i)'{--ignore-case,-i}'[ignore case]' - '(--regexp -r)'{--regexp,-r}'[regular expression]' - '(-V --version)'{-V,--version}'[version]' - '(-a --architecture)'{-a,--architecture}'[architecture]:architecture:(alpha arm hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 sparc)' - '(-s --sources-list)'{-s,--sources-list}'[source.list file]:file:_files' - '(-l --package-only)'{-l,--package-only}'[only display package name]' - '(-F --fixed-string)'{-F,--fixed-string}'[do not expand search pattern]' - '(-y --dummy)'{-y,--dummy}'[run in dummy mode]' - '(-h --help)'{-h,--help}'[display help screen]' - '1: :->cmds' - '*: :->args' - ) - _arguments -S $arguments +local curcontext="$curcontext" state line expl cmds ret=1 +typeset -A opt_args - case $state in - cmds) - cmds=( - 'update:resynchronize package contents' - 'search:search in which package file is included' - 'list:list contents of a package' - 'show:alias for list' - 'purge:remove all Contents-<ARCH>.gz files in cache directory' - ) - _describe -t commands 'apt-list command' cmds && ret=0 +_arguments -C -S \ + '(--cache -c)'{--cache,-c}'[cache directory]:directory:_directories' \ + '(-v --verbose)'{-v,--verbose}'[verbose]' \ + '(--cdrom-mount -d)'{--cdrom-mount,-d}'[cdrom mount point]:directory:_directories' \ + '(--from-file -f --from-deb -D)'{--from-file,-f}'[read patterns from given file]' \ + '(--from-deb -D --from-file -f)'{--from-dev,-D}'[use contents of given .deb archives as patterns]' \ + '(--ignore-case -i)'{--ignore-case,-i}'[ignore case]' \ + '(--regexp -x)'{--regexp,-x}'[regular expression]' \ + '(-V --version)'{-V,--version}'[version]' \ + '(-a --architecture)'{-a,--architecture}'[architecture]:architecture:_deb_architectures' \ + '(-s --sources-list)'{-s,--sources-list}'[source.list file]:file:_files' \ + '(-l --package-only)'{-l,--package-only}'[only display package name]' \ + '(-N --non-interactive)'{-N,--non-interactive}'[skip schemes requiring user input]' \ + '(-F --fixed-string)'{-F,--fixed-string}'[do not expand search pattern]' \ + '(-y --dummy)'{-y,--dummy}'[run in dummy mode]' \ + '(-)'{-h,--help}'[display help screen]' \ + '1: :->cmds' \ + '*: :->args' && ret=0 + +case $state in + cmds) + cmds=( + 'update:resynchronize package contents' + {find,search}:'search in which package file is included' + {list,show}:'list contents of a package' + 'purge:remove all Contents-<ARCH>.gz files in cache directory' + ) + _describe -t commands 'apt-list command' cmds + ;; + args) + case $line[1] in + search|find) + if (( $#opt_args[(I)(-D|--from-deb)] )); then + _wanted files expl 'debian package' _files -g '*.deb(-.)' + elif (( $#opt_args[(I)(-f|--from-file)] )); then + _files + else + _message -e patterns "pattern" + fi + ;; + list|show) + _deb_packages avail ;; - args) - case $line[1] in - search) - _message "pattern" - ;; - list|show) - _deb_packages avail - ;; - update|purge) - # do nothing - ;; - *) - _message "command $line[1] not available" - ;; - esac + update|purge) + # do nothing + ;; + *) + _message "command $line[1] not available" ;; esac + ;; +esac && ret=0 -} - -_apt-file "$@" +return ret diff --git a/Completion/Debian/Command/_apt-move b/Completion/Debian/Command/_apt-move index a72378e6f..6911ef6f1 100644 --- a/Completion/Debian/Command/_apt-move +++ b/Completion/Debian/Command/_apt-move @@ -1,6 +1,6 @@ #compdef apt-move -local curcontext="$curcontext" state line cmds ret=1 +local curcontext="$curcontext" state line expl cmds ret=1 typeset -A opt_args _arguments -C \ @@ -45,7 +45,10 @@ case $state in _files -g "*.d(sc|eb)(-.)" && ret=0 ;; listbin) - _wanted lists expl list compadd mirror sync repo + _wanted lists expl list compadd mirror sync repo && ret=0 + ;; + *) + _default && ret=0 ;; esac ;; diff --git a/Completion/Debian/Command/_bts b/Completion/Debian/Command/_bts index 4907d15c1..9f1f77bf4 100644 --- a/Completion/Debian/Command/_bts +++ b/Completion/Debian/Command/_bts @@ -40,10 +40,12 @@ case "$words[1]" in ;; (show|bugs) if [[ CURRENT -eq 2 ]]; then - _wanted package expl 'package' _deb_packages avail - _wanted maintainer expl 'package maintainer' compadd $DEBEMAIL + _alternative \ + 'packages:package:_deb_packages avail' \ + "emails:package maintainer:compadd $DEBEMAIL" + else + _wanted sep expl 'separator' compadd -S ' ' , . fi - _wanted sep expl 'separator' compadd -S ' ' , . ;; reopen) if [[ CURRENT -eq 2 ]]; then diff --git a/Completion/Debian/Command/_dak b/Completion/Debian/Command/_dak index 840fc0017..086196c4a 100644 --- a/Completion/Debian/Command/_dak +++ b/Completion/Debian/Command/_dak @@ -1,31 +1,26 @@ #compdef dak -local curcontext="$curcontext" state line expl cmd args ret=1 -typeset -A opt_args +local expl cmd args ret=1 -_arguments -C \ - '1: :->cmd' \ - '*:: :->args' && ret=0 - -if (( ! $+_dak_cmds )); then +if (( CURRENT == 2 )); then + if (( ! $+_dak_cmds )); then typeset -gH _dak_cmds _dak_cmds=(${${${(f)${"$(_call_program dak dak --help)"#*Availa#ble commands:}}#[^a-z] ##}%%[ ]*}) -fi + fi -if [[ $state != 'args' ]]; then - _describe -t subcommand 'subcommand' _dak_cmds - return 0 + _describe -t subcommands 'subcommand' _dak_cmds + return fi -cmd="$words[1]" -curcontext="${curcontext%:*:*}:dak-$cmd:" +cmd="$words[2]" +local curcontext="${curcontext%:*:*}:dak-$cmd:" args=( '(-)'{--help,-h}'[show help message]' ) case $cmd in (ls) args+=( - '(-a --architecture)'{-a,--architecture=}':arch:_values -s , "architecture list" source all alpha amd64 arm hppa hurd-i386 i386 ia64 mips mipsel' + '(-a --architecture)'{-a,--architecture=}':arch:_sequence _deb_architectures -a "all source"' '(-b --binary-type)'{-b,--binary-type=}':type:(deb udeb)' '(-c --component)'{-c,--component=}':component:_values -s , "component list" main contrib non-free' '(-g --greaterorequal)'{-g,--greaterorequal} @@ -70,7 +65,7 @@ case $cmd in ;; (rm) args+=( - '(-a --architecture)'{-a,--architecture=}':arch:_values -s , "architecture list" source all alpha amd64 arm hppa hurd-i386 i386 ia64 mips mipsel' + '(-a --architecture)'{-a,--architecture=}':arch:_sequence _deb_architectures -a "all source"' '(-b --binary)'{-b,--binary}'[remove binaries only]' '(-c --component)'{-c,--component=}':component:_values -s , "component list" main contrib non-free' '(-C --carbon-copy)'{-C,--carbon-copy=}':cc address:_email_addresses' @@ -96,7 +91,7 @@ case $cmd in (make-suite-file-list) args+=( - '(-a --architecture)'{-a,--architecture=}':arch:_values -s , "architecture list" source all alpha amd64 arm hppa hurd-i386 i386 ia64 mips mipsel' + '(-a --architecture)'{-a,--architecture=}':arch:_sequence _deb_architectures -a "all source"' '(-c --component)'{-c,--component=}':component:_values -s , "component list" main contrib non-free' '(-n --no-delete)'{-n,--no-delete}'[do not delete older versions]' '(-s --suite)'{-s,--suite=}':suite:_values -s , "suite list" oldstable stable testing unstable experimental' @@ -239,10 +234,10 @@ case $cmd in ;; (*) - _files + args+=( '*: :_default' ) ;; esac _arguments -s "$args[@]" && ret=0 -return $ret +return ret diff --git a/Completion/Debian/Command/_dchroot b/Completion/Debian/Command/_dchroot index 43a797d83..c26e5691a 100644 --- a/Completion/Debian/Command/_dchroot +++ b/Completion/Debian/Command/_dchroot @@ -20,8 +20,8 @@ _arguments -S \ '*::arguments: _normal' && return 0 case "$state" in - (chroot) - _wanted tag expl 'chroot' \ - compadd ${(os:,:)${${${"$(dchroot -l )"#*: }// /}//[[\]]/,}} - ;; + chroot) + _wanted -C $context chroots expl 'chroot' \ + compadd ${(os:,:)${${${"$(_call_program chroots dchroot -l )"#*: }// /}//[[\]]/,}} + ;; esac diff --git a/Completion/Debian/Command/_dchroot-dsa b/Completion/Debian/Command/_dchroot-dsa index bed4bcf19..d4668b553 100644 --- a/Completion/Debian/Command/_dchroot-dsa +++ b/Completion/Debian/Command/_dchroot-dsa @@ -19,8 +19,8 @@ _arguments -S \ '*::arguments: _normal' && return 0 case "$state" in - (chroot) - _wanted tag expl 'chroot' \ - compadd ${(os:,:)${${${"$(dchroot -l )"#*: }// /}//[[\]]/,}} - ;; + chroot) + _wanted -C $context chroots expl 'chroot' \ + compadd ${(os:,:)${${${"$(_call_program chroots dchroot -l )"#*: }// /}//[[\]]/,}} + ;; esac diff --git a/Completion/Debian/Command/_dpkg-buildpackage b/Completion/Debian/Command/_dpkg-buildpackage index d6f5c5f0a..b0eea5783 100644 --- a/Completion/Debian/Command/_dpkg-buildpackage +++ b/Completion/Debian/Command/_dpkg-buildpackage @@ -5,7 +5,7 @@ _arguments \ '-B[binary-only build, no source or arch-indep binaries]' \ '-S[source-only build, no binaries]' \ '-s-:source generation:((i\:default a\:force\ inclusion\ of\ original\ source d\:force\ exclusion\ of\ original\ source))' \ - '-a-:architecture:(alpha amd64 arm hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 sparc)' \ + '-a-:architecture:_deb_architectures' \ '-v-:version:' \ '-C-:changes description:_files' \ '-m-:maintainer address:_email_addresses' \ diff --git a/Completion/Debian/Command/_dpkg-repack b/Completion/Debian/Command/_dpkg-repack index 5d625a5ce..37f800516 100644 --- a/Completion/Debian/Command/_dpkg-repack +++ b/Completion/Debian/Command/_dpkg-repack @@ -2,6 +2,6 @@ _arguments \ '--root=[take package from filesystem rooted on <dir>]:root dir:_files -/' \ - '--arch=[force the package to be built for architecture <arch>]:architecture:(alpha amd64 arm hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 sparc)' \ + '--arch=[force the package to be built for specified architecture]:architecture:_deb_architectures' \ '--generate[generate build directory but do not build deb]' \ '*:package:_deb_packages xinstalled' diff --git a/Completion/Debian/Command/_lintian b/Completion/Debian/Command/_lintian index 554be4550..773e7a182 100644 --- a/Completion/Debian/Command/_lintian +++ b/Completion/Debian/Command/_lintian @@ -31,7 +31,7 @@ case "$service" in '--archivedir:archive directory:_files -/' \ '--dist:distribution:(woody sarge sid)' \ '--section:release:(main contrib non-free)' \ - '--arch:architecture:(alpha arm hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 sparc)' \ + '--arch:architecture:_deb_architectures' \ '--root:root directory:_files -/' \ '(-a --all)'{-a,--all}'[check all packages in the distribution]' \ '(-b --binary)'{-b,--binary}'[the following packages are binary]' \ diff --git a/Completion/Debian/Command/_madison b/Completion/Debian/Command/_madison index fc4821e91..445b79a45 100644 --- a/Completion/Debian/Command/_madison +++ b/Completion/Debian/Command/_madison @@ -1,7 +1,7 @@ #compdef madison rmadison _arguments \ - '(-a --architecture)'{-a,--architecture=}':arch:_values -s , "architecture list" source all alpha arm hppa hurd-i386 i386 ia64 mips mipsel' \ + '(-a --architecture)'{-a,--architecture=}':arch:_sequence _deb_architectures -a "all source" -' \ '(-b --binary)'{-b,--binary-type=}':type:(deb udeb)' \ '(-c --component)'{-c,--component=}':component:_values -s , "component list" main contrib non-free' \ '(-g --greaterorequal)'{-g,--greaterorequal} \ diff --git a/Completion/Debian/Command/_make-kpkg b/Completion/Debian/Command/_make-kpkg index c079d9aa0..55adf882f 100644 --- a/Completion/Debian/Command/_make-kpkg +++ b/Completion/Debian/Command/_make-kpkg @@ -1,9 +1,9 @@ #compdef make-kpkg -local context state line +local curcontext="$curcontext" state line typeset -A opt_args -_arguments \ +_arguments -C \ '--help[display help message]' \ '--revision[change Debian revision number]:number:' \ '--append-to-version[specify additional kernel sub-version]:suffix:' \ @@ -45,7 +45,7 @@ _arguments \ configure\:"configure the kernel" \ debian\:"creates the debian/ directory" \ libc-kheaders\:"create the kernel headers package needed by libc" \ - ))' && return 0 + ))' && return case "$state" in (addedmodules) diff --git a/Completion/Debian/Command/_pbuilder b/Completion/Debian/Command/_pbuilder index 7811d567b..9322d036a 100644 --- a/Completion/Debian/Command/_pbuilder +++ b/Completion/Debian/Command/_pbuilder @@ -14,8 +14,8 @@ else '--buildresult:location:_files -/' \ '--mirror:URL:_urls' \ '--othermirror:URL:_urls' \ - '--distribution:suite:(breezy dapper edgy etch feisty gutsy hardy hoary intrepid jaunty karmic lenny lucid potato sarge sid squeeze warty woody' \ - '--architecture:architecture:(alpha amd64 armel hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 sparc)' \ + '--distribution:suite:(breezy dapper edgy etch feisty gutsy hardy hoary intrepid jaunty jessie karmic lenny lucid potato sarge sid squeeze warty woody' \ + '--architecture:architecture:i_deb_architectures' \ '--components:component:(main contrib non-free)' \ '--override-config' \ '--hookdir:location:_files -/' \ diff --git a/Completion/Debian/Command/_reprepro b/Completion/Debian/Command/_reprepro index 44ed1548c..d1e124eef 100644 --- a/Completion/Debian/Command/_reprepro +++ b/Completion/Debian/Command/_reprepro @@ -1,10 +1,10 @@ #compdef reprepro -local context state line distfile +local curcontext="$curcontext" state line expl distfile ret=1 typeset -A opt_args local -a codenames -_arguments \ +_arguments -C \ '(-h --help)'{-h,--help}'[display help]' \ '*'{-v,-V,--verbose}'[be more verbose]' \ '--silent[be less verbose]' \ @@ -17,7 +17,7 @@ _arguments \ '--listdir:list dir:_files -/' \ '--methoddir:method dir:_files -/' \ '(-C --component)'{-C,--component}':component:(component1 component2)' \ - '(-A --architecture)'{-A,--architecture}':architecture:(amd64 sparc)' \ + '(-A --architecture)'{-A,--architecture}':architecture:_sequence -s "|" _deb_architectures -' \ '(-T --type)'{-T,--type}':file type:(dsc deb udeb)' \ '(-S --section)'{-S,--section}':section:(section1 section2)' \ '(-P --priority)'{-P,--priority}':priority:(high low)' \ @@ -40,12 +40,11 @@ _arguments \ rereference dumpreferences dumpunreferenced deleteunreferenced reoverride dumptracks retrack removealltracks removetrack tidytracks copy clearvanished gensnapshot rerunnotifiers)' \ - '*::subcmd:->subcmd' && return 0 + '*::subcmd:->subcmd' && ret=0 case "$state" in - (subcmd) - - case "$words[1]" in + subcmd) + case "$words[1]" in (export|update|iteratedupdate|checkupdate|predelete|pull|checkpull|check) if [[ -n "$opt_args[--confdir]" ]]; then distfile=${opt_args[--confdir]}/distributions @@ -60,11 +59,13 @@ case "$state" in fi codenames=($(awk '/^[Cc][Oo][Dd][Ee][Nn][Aa][Mm][Ee]: / {$1="";print}' "$distfile")) - _wanted -V 'codenames' expl 'codename' compadd -a codenames - ;; + _wanted -V 'codenames' expl 'codename' compadd -a codenames && ret=0 + ;; (*) - _files - ;; - esac + _files && ret=0 + ;; + esac ;; esac + +return ret diff --git a/Completion/Debian/Command/_svn-buildpackage b/Completion/Debian/Command/_svn-buildpackage index 0b4d50125..e0f925896 100644 --- a/Completion/Debian/Command/_svn-buildpackage +++ b/Completion/Debian/Command/_svn-buildpackage @@ -28,8 +28,8 @@ _arguments \ '-B[binary-only build, no source or arch-indep binaries]' \ '-S[source-only build, no binaries]' \ '-s-:source generation:((i\:default a\:force\ inclusion\ of\ original\ source d\:force\ exclusion\ of\ original\ source))' \ - '-a-:architecture:(alpha amd64 arm hppa hurd-i386 i386 ia64 m68k mips mipsel powerpc s390 sparc)' \ - '-v-:version:' \ + '-a-:architecture:_deb_architectures' \ + '-v-:version' \ '-C-:changes description:_files' \ '-m-:maintainer address:_email_addresses' \ '-e-:maintainer address:_email_addresses' \ diff --git a/Completion/Debian/Command/_update-alternatives b/Completion/Debian/Command/_update-alternatives index ccf5084bf..31128dd82 100644 --- a/Completion/Debian/Command/_update-alternatives +++ b/Completion/Debian/Command/_update-alternatives @@ -1,6 +1,6 @@ #compdef update-alternatives -local curcontext="$curcontext" context state line alterdir +local curcontext="$curcontext" state line alterdir ret if [[ -d /var/lib/dpkg/alternatives ]]; then alterdir=/var/lib/dpkg/alternatives diff --git a/Completion/Debian/Command/_vim-addons b/Completion/Debian/Command/_vim-addons index dbd0ee31d..0ad39955d 100644 --- a/Completion/Debian/Command/_vim-addons +++ b/Completion/Debian/Command/_vim-addons @@ -1,47 +1,48 @@ #compdef vim-addons -local state line cmds ret=1 +local context state line expl ret=1 typeset -A opt_args -_arguments -C \ - {-q,--query}'[be quiet and make the output more parseable]' \ - {-r,--registry-dir}'[set the registry directory]' \ - {-s,--source-dir}'[set addon source directory]' \ - {-t,--target-dir}'[set addon target directory]' \ - {-v,--verbose}'[increase verbosity]' \ - {-y,--system-dir}'[set system-wide target directory]' \ - {-h,--help}'[help]' \ - {-w,--system-wide}'[set target directory to the system-wide one (overrides -t)]' \ - '1: :->cmds' \ - '*: :->args' && ret=0 - +_arguments \ + '(-q --query)'{-q,--query}'[be quiet and make the output more parseable]' \ + '(-r --registry-dir)'{-r,--registry-dir}'[set the registry directory]' \ + '(-s --source-dir)'{-s,--source-dir}'[set addon source directory]' \ + '(-t --target-dir -w --system-wide)'{-t,--target-dir}'[set addon target directory]' \ + '(-v --verbose -z --silent)'{-v,--verbose}'[increase verbosity]' \ + '(y --system-dir)'{-y,--system-dir}'[set system-wide target directory]' \ + '(-)'{-h,--help}'[show help information]' \ + '(-w --system-wide -t --target-dir)'{-w,--system-wide}'[use system-wide target directory]' \ + '(-z --silent -v --verbose)'{-z,--silent}'[supress most output]' \ + '1:commands:(( + install\:install\ specified\ addons + remove\:remove\ specified\ addons + list\:list\ available\ addons\ in\ registry + status\:list\ status\ of\ addons + disable\:disable\ specified\ addons + enable\:undo\ effects\ of\ previous\ disable + files\:list\ files\ composing\ the\ specified\ addon + show\:display\ detailed\ information\ on\ specified\ addon + ))' \ + '*: :->args' && ret=0 + case $state in - cmds) - cmds=( - 'install:install the specified addon' - 'remove:remove the specified addon' - 'list:list available addons in registry' - 'status:list the status of addons' - 'disable:disable the specified addons' - 'amend:under the effects of the previous disable' - 'files:list the files composing the specified addon' - 'show:display detailed information about the specified addon' - ) - _describe -t commands 'vim-addons command' cmds && ret=0 - ;; args) case $line[1] in install) - _wanted addon expl 'addon' compadd $(command vim-addons -q | awk '$2 == "removed" { print $1 }') && ret=0 + _wanted -C $context addons expl 'addon' compadd - \ + ${${(M)${(f)"$(_call_program addons vim-addons -q)"}:#*removed}%$'\t'*} && ret=0 ;; - amend) - _wanted addon expl 'addon' compadd $(command vim-addons -q | awk '$2 == "disabled" { print $1 }') && ret=0 + enable) + _wanted -C $context addons expl 'addon' compadd - \ + ${${(M)${(f)"$(_call_program addons vim-addons -q)"}:#*disabled}%$'\t'*} && ret=0 ;; remove) - _wanted addon expl 'addon' compadd $(command vim-addons -q | awk '$2 ~ /disabled|installed/ { print $1 }') && ret=0 + _wanted -C $context addons expl 'addon' compadd - \ + ${${(M)${(f)"$(_call_program addons vim-addons -q)"}:#*(disabled|installed)}%$'\t'*} && ret=0 ;; - files|status|disable|show) - _wanted addon expl 'addon' compadd $(command vim-addons list) && ret=0 + *) + _wanted -C $context addons expl 'addon' compadd - \ + $(_call_program addons vim-addons list) && ret=0 ;; esac ;; diff --git a/Completion/Debian/Type/_deb_architectures b/Completion/Debian/Type/_deb_architectures new file mode 100644 index 000000000..22c43dd3e --- /dev/null +++ b/Completion/Debian/Type/_deb_architectures @@ -0,0 +1,9 @@ +#autoload + +local extra +zparseopts -E -D -a extra a: + +_description architectures expl 'architecture' +compadd "$@" "$expl[@]" alpha amd64 arm64 armel armhf hppa hurd-i386 i386 ia64 \ + kfreebsd-amd64 kfreebsd-i386 m68k mips mipsel powerpc powerpcspe ppc64 \ + ppc64el s390x sh4 sparc sparc64 x32 ${=extra[2]} diff --git a/Completion/Linux/Command/_docker b/Completion/Linux/Command/_docker deleted file mode 100644 index faf17b2be..000000000 --- a/Completion/Linux/Command/_docker +++ /dev/null @@ -1,410 +0,0 @@ -#compdef docker -# -# zsh completion for docker (http://docker.com) -# -# version: 0.3.0 -# github: https://github.com/felixr/docker-zsh-completion -# -# contributers: -# - Felix Riedel -# - Vincent Bernat -# -# license: -# -# Copyright (c) 2013, Felix Riedel -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# * Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# * Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# * Neither the name of the <organization> nor the -# names of its contributors may be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY -# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -# - -__parse_docker_list() { - awk ' -NR == 1 { - idx=1;i=0;f[i]=0 - header=$0 - while ( match(header, / ([A-Z]+|[A-Z]+ [A-Z]+)/) ) { - idx += RSTART+1 - f[++i]=idx - header = substr($0,idx) - } - f[++i]=999 -} - -NR > 1 '"$1"' { - for(j=0;j<i;j++) { - x[j] = substr($0, f[j], f[j+1]-f[j]-1) - gsub(/[ ]+$/, "", x[j]) - } - printf("%s:%7s, %s\n", x[0], x[3], x[1]) - if (x[6] != "") { - split(x[6], names, /,/) - for (name in names) printf("%s:%7s, %s\n", names[name], x[3], x[1]) - } -} -'| sed -e 's/ \([hdwm]\)\(inutes\|ays\|ours\|eeks\)/\1/' -} - -__docker_stoppedcontainers() { - local expl - declare -a stoppedcontainers - stoppedcontainers=(${(f)"$(_call_program commands docker ps -a | __parse_docker_list '&& / Exit/')"}) - _describe -t containers-stopped "Stopped Containers" stoppedcontainers "$@" -} - -__docker_runningcontainers() { - local expl - declare -a containers - - containers=(${(f)"$(_call_program commands docker ps | __parse_docker_list)"}) - _describe -t containers-active "Running Containers" containers "$@" -} - -__docker_containers () { - __docker_stoppedcontainers "$@" - __docker_runningcontainers "$@" -} - -__docker_images () { - local expl - declare -a images - images=(${(f)"$(_call_program commands docker images | awk '(NR > 1 && $1 != "<none>"){printf("%s", $1);if ($2 != "<none>") printf("\\:%s", $2); printf("\n")}')"}) - images=($images ${(f)"$(_call_program commands docker images | awk '(NR > 1){printf("%s:%-15s in %s\n", $3,$2,$1)}')"}) - _describe -t docker-images "Images" images -} - -__docker_tags() { - local expl - declare -a tags - tags=(${(f)"$(_call_program commands docker images | awk '(NR>1){print $2}'| sort | uniq)"}) - _describe -t docker-tags "tags" tags -} - -__docker_repositories_with_tags() { - if compset -P '*:'; then - __docker_tags - else - __docker_repositories -qS ":" - fi -} - -__docker_search() { - # declare -a dockersearch - local cache_policy - zstyle -s ":completion:${curcontext}:" cache-policy cache_policy - if [[ -z "$cache_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy - fi - - local searchterm cachename - searchterm="${words[$CURRENT]%/}" - cachename=_docker-search-$searchterm - - local expl - local -a result - if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \ - && ! _retrieve_cache ${cachename#_}; then - _message "Searching for ${searchterm}..." - result=(${(f)"$(_call_program commands docker search ${searchterm} | awk '(NR>2){print $1}')"}) - _store_cache ${cachename#_} result - fi - _wanted dockersearch expl 'Available images' compadd -a result -} - -__docker_caching_policy() -{ - # oldp=( "$1"(Nmh+24) ) # 24 hour - oldp=( "$1"(Nmh+1) ) # 24 hour - (( $#oldp )) -} - - -__docker_repositories () { - local expl - declare -a repos - repos=(${(f)"$(_call_program commands docker images | sed -e '1d' -e 's/[ ].*//' | sort | uniq)"}) - _describe -t docker-repos "Repositories" repos "$@" -} - -__docker_commands () { - # local -a _docker_subcommands - local cache_policy - - zstyle -s ":completion:${curcontext}:" cache-policy cache_policy - if [[ -z "$cache_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy - fi - - if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \ - && ! _retrieve_cache docker_subcommands; - then - _docker_subcommands=(${${(f)"$(_call_program commands - docker 2>&1 | sed -e '1,6d' -e '/^[ ]*$/d' -e 's/[ ]*\([^ ]\+\)\s*\([^ ].*\)/\1:\2/' )"}}) - _docker_subcommands=($_docker_subcommands 'help:Show help for a command') - _store_cache docker_subcommands _docker_subcommands - fi - _describe -t docker-commands "docker command" _docker_subcommands -} - -__docker_subcommand () { - local -a _command_args - case "$words[1]" in - (attach) - _arguments \ - '--no-stdin[Do not attach stdin]' \ - '--sig-proxy[Proxify all received signal]' \ - ':containers:__docker_runningcontainers' - ;; - (build) - _arguments \ - '--no-cache[Do not use cache when building the image]' \ - '-q[Suppress verbose build output]' \ - '--rm[Remove intermediate containers after a successful build]' \ - '-t=-:repository:__docker_repositories_with_tags' \ - ':path or URL:_directories' - ;; - (commit) - _arguments \ - '--author=-[Author]:author: ' \ - '-m=-[Commit message]:message: ' \ - '--run=-[Configuration automatically applied when the image is run]:configuration: ' \ - ':container:__docker_containers' \ - ':repository:__docker_repositories_with_tags' - ;; - (cp) - _arguments \ - ':container:->container' \ - ':hostpath:_files' - case $state in - (container) - if compset -P '*:'; then - _files - else - __docker_containers -qS ":" - fi - ;; - esac - ;; - (diff|export) - _arguments '*:containers:__docker_containers' - ;; - (history) - _arguments \ - '--no-trunc[Do not truncate output]' \ - '-q[Only show numeric IDs]' \ - '*:images:__docker_images' - ;; - (images) - _arguments \ - '-a[Show all images]' \ - '--no-trunc[Do not truncate output]' \ - '-q[Only show numeric IDs]' \ - '--tree[Output graph in tree format]' \ - '--viz[Output graph in graphviz format]' \ - ':repository:__docker_repositories' - ;; - (inspect) - _arguments \ - '--format=-[Format the output using the given go template]:template: ' \ - '*:containers:__docker_containers' - ;; - (import) - _arguments \ - ':URL:(- http:// file://)' \ - ':repository:__docker_repositories_with_tags' - ;; - (info) - ;; - (import) - _arguments \ - ':URL:(- http:// file://)' \ - ':repository:__docker_repositories_with_tags' - ;; - (insert) - _arguments '1:containers:__docker_containers' \ - '2:URL:(http:// file://)' \ - '3:file:_files' - ;; - (kill) - _arguments '*:containers:__docker_runningcontainers' - ;; - (load) - ;; - (login) - _arguments \ - '-e=-[Email]:email: ' \ - '-p=-[Password]:password: ' \ - '-u=-[Username]:username: ' \ - ':server: ' - ;; - (logs) - _arguments \ - '-f[Follow log output]' \ - '*:containers:__docker_containers' - ;; - (port) - _arguments \ - '1:containers:__docker_runningcontainers' \ - '2:port:_ports' - ;; - (start) - _arguments \ - '-a[Attach container'"'"'s stdout/stderr and forward all signals]' \ - '-i[Attach container'"'"'s stding]' \ - '*:containers:__docker_stoppedcontainers' - ;; - (rm) - _arguments \ - '--link[Remove the specified link and not the underlying container]' \ - '-v[Remove the volumes associated to the container]' \ - '*:containers:__docker_stoppedcontainers' - ;; - (rmi) - _arguments \ - '*:images:__docker_images' - ;; - (restart|stop) - _arguments '-t=-[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)' \ - '*:containers:__docker_runningcontainers' - ;; - (top) - _arguments \ - '1:containers:__docker_runningcontainers' \ - '(-)*:: :->ps-arguments' - case $state in - (ps-arguments) - _ps - ;; - esac - - ;; - (ps) - _arguments \ - '-a[Show all containers]' \ - '--before=-[Show only container created before...]:containers:__docker_containers' \ - '-l[Show only the latest created container]' \ - '-n=-[Show n last created containers, include non-running one]:n:(1 5 10 25 50)' \ - '--no-trunc[Do not truncate output]' \ - '-q[Only show numeric IDs]' \ - '-s[Display sizes]' \ - '--since=-[Show only containers created since...]:containers:__docker_containers' - ;; - (tag) - _arguments \ - '-f[force]'\ - ':image:__docker_images'\ - ':repository:__docker_repositories_with_tags' - ;; - (run) - _arguments \ - '-P[Publish all exposed ports to the host]' \ - '-a[Attach to stdin, stdout or stderr]' \ - '-c=-[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)' \ - '--cidfile=-[Write the container ID to the file]:CID file:_files' \ - '-d[Detached mode: leave the container running in the background]' \ - '*--dns=-[Set custom dns servers]:dns server: ' \ - '*-e=-[Set environment variables]:environment variable: ' \ - '--entrypoint=-[Overwrite the default entrypoint of the image]:entry point: ' \ - '*--expose=-[Expose a port from the container without publishing it]: ' \ - '-h=-[Container host name]:hostname:_hosts' \ - '-i[Keep stdin open even if not attached]' \ - '--link=-[Add link to another container]:link:->link' \ - '--lxc-conf=-[Add custom lxc options]:lxc options: ' \ - '-m=-[Memory limit (in bytes)]:limit: ' \ - '--name=-[Container name]:name: ' \ - '*-p=-[Expose a container'"'"'s port to the host]:port:_ports' \ - '--privileged[Give extended privileges to this container]' \ - '--rm[Remove intermediate containers when it exits]' \ - '--sig-proxy[Proxify all received signal]' \ - '-t[Allocate a pseudo-tty]' \ - '-u=-[Username or UID]:user:_users' \ - '*-v=-[Bind mount a volume (e.g. from the host: -v /host:/container, from docker: -v /container)]:volume: '\ - '--volumes-from=-[Mount volumes from the specified container]:volume: ' \ - '-w=-[Working directory inside the container]:directory:_directories' \ - '(-):images:__docker_images' \ - '(-):command: _command_names -e' \ - '*::arguments: _normal' - - case $state in - (link) - if compset -P '*:'; then - _wanted alias expl 'Alias' compadd -E "" - else - __docker_runningcontainers -qS ":" - fi - ;; - esac - - ;; - (pull|search) - _arguments ':name:__docker_search' - ;; - (push) - _arguments ':repository:__docker_repositories_with_tags' - ;; - (save) - _arguments \ - ':images:__docker_images' - ;; - (wait) - _arguments ':containers:__docker_runningcontainers' - ;; - (help) - _arguments ':subcommand:__docker_commands' - ;; - (*) - _message 'Unknown sub command' - esac - -} - -_docker () { - # Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`. - # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`. - if [[ $service != docker ]]; then - _call_function - _$service - return - fi - - local curcontext="$curcontext" state line - typeset -A opt_args - - _arguments -C \ - '-H=-[tcp://host:port to bind/connect to]:socket: ' \ - '(-): :->command' \ - '(-)*:: :->option-or-argument' - - if (( CURRENT == 1 )); then - - fi - case $state in - (command) - __docker_commands - ;; - (option-or-argument) - curcontext=${curcontext%:*:*}:docker-$words[1]: - __docker_subcommand - ;; - esac -} - -_docker "$@" diff --git a/Completion/Linux/Command/_modutils b/Completion/Linux/Command/_modutils index 66e65d32e..0732aa106 100644 --- a/Completion/Linux/Command/_modutils +++ b/Completion/Linux/Command/_modutils @@ -107,7 +107,7 @@ _modutils() { if _cache_invalid modules-$kver || ! _retrieve_cache modules-$kver; then # 2011-01-02 gi1242: Do we need .o files? Or is .ko enough? - modules=( $modules_dir/$kver/(*~(source|build))/**/*.(o|ko|ko.gz)(.:t:r:r) ) + modules=( $modules_dir/$kver/(*~(source|build))/**/*.(o|ko|ko.gz|.ko.xz)(.:t:r:r) ) _store_cache modules-$kver modules fi diff --git a/Completion/Linux/Command/_qdbus b/Completion/Linux/Command/_qdbus new file mode 100644 index 000000000..95a4d5243 --- /dev/null +++ b/Completion/Linux/Command/_qdbus @@ -0,0 +1,114 @@ +#compdef qdbus +# +# Copyright (C) 2015 Thomas Mitterfellner <thomas.mitterfellner@gmail.com> +# +# This file is released under the GPLv2. +# +# version 0.1 + +# get the type of a method: 1 means function, 2 means property +getType () { + case "$1" in + "method"*) echo 1 ;; + "property"*) echo 2 ;; + *) echo 0 ;; + esac +} + +# get the index of a method in an array of methods +getIndex () { + local e + local index + local type_ + index=0 + for e in "${@:2}"; do + index=$(( index + 1 )) + type_=$(getType "$e") + if [[ $type_ == 1 ]] ; then + if [[ "$e" == *"$1("* ]] ; then + echo $index + return 0 + fi + elif [[ $type_ == 2 ]] ; then + if [[ "$e" == *"$1" ]] ; then + echo $index + return 0 + fi + fi + done + echo 0 +} + +_qdbus() { + local curcontext="$curcontext" state line + local services + local path_ + local methods + local names + local types + local properties + local index + typeset -A opt_args + + _arguments "--system[connect to system bus]"\ + "--literal[print literal replies]"\ + "1:service name:->service"\ + "2:path:->path"\ + "3:method:->method"\ + "*:arguments:->arguments" + + case $state in + service) + services=( $(qdbus ${words[@]:1:-1} | grep -E '^([^:])') ) + compadd "$@" $services + ;; + + path) + path_=( $(qdbus ${words[@]:1:-1} 2>/dev/null) ) + + compadd "$@" $path_ + ;; + + method) + IFS=$'\n' + methods=( $(qdbus ${words[@]:1:-1} | \ + grep -e "^method" | \ + sed -r 's/method (.+) (.+)\((.*)\)/\2:\1(\3)/g' 2>/dev/null) ) + properties=( $(qdbus ${words[@]:1:-1} | \ + grep -e "^property" | \ + sed -r 's/property (.+) (.+) (.+)/\3:\1 \2/g' 2>/dev/null) ) + + _describe properties properties -J properties + _describe methods methods -J methods + ;; + + arguments) + IFS=$'\n' + + path_pos=$(( ${(M)#words:#--*} + 2)) + method_pos=$(( $path_pos + 2)) + names=( $(qdbus ${words[@]:1:$path_pos} | grep -e '^[mp]' 2>/dev/null) ) + index=$(getIndex "${words[$method_pos]}" $names[@]) + method=$names[$index] + + arg_pos=$(( ${#words} - $method_pos )) + if [[ $(getType "$method") -eq 1 ]] ; then + method_args="$(echo $method | sed -r 's/(.+) (.+) (.+)\((.*)\)/\4/g')" + IFS=$',' method_args_=(${=method_args}) + num_args=${#method_args_} + if [[ $arg_pos -le $num_args ]] ; then + _message "${method_args_[$arg_pos]}" + fi + else + property_=$(echo "$method" |\ + sed -r 's/property (.+) (.+) (.+)/\1 \2/g') + if [[ $arg_pos -eq 1 ]] ; then + + _message ${property_} + fi + fi + ;; + esac +} + +_qdbus "$@" diff --git a/Completion/Linux/Command/_strace b/Completion/Linux/Command/_strace index 45ebfcf1a..d6dabfd24 100644 --- a/Completion/Linux/Command/_strace +++ b/Completion/Linux/Command/_strace @@ -5,6 +5,7 @@ # - allow negated calls (e.g. -e!write) _sys_calls () { local expl + local -a sys_calls sys_calls=(_llseek _newselect _sysctl accept access acct adjtimex afs_syscall alarm bdflush bind break brk cacheflush diff --git a/Completion/Linux/Command/_sysstat b/Completion/Linux/Command/_sysstat index 60de9d899..2a7128c23 100644 --- a/Completion/Linux/Command/_sysstat +++ b/Completion/Linux/Command/_sysstat @@ -4,80 +4,73 @@ # sysstat-nfsiostat - there seems to be two nfsiostat(1)s. one from oracle and one by redhat. _mpstat() { - local ret=1 _arguments : \ '-A[equivalent to -u -I ALL -P ALL]' \ - '-I[report interrupt statistics]:interrupts:(SUM CPU SCPU ALL)' \ - '-P[specify processor number]:processor: _values -s "," processor ON ALL' \ + '-I[report interrupt statistics]:interrupt:(SUM CPU SCPU ALL)' \ + '-P[specify processor number]:processor: _values -s "," processor ON ALL {1..$(_call_program processors getconf _NPROCESSORS_ONLN)}' \ '-u[report CPU utilization]' \ '-V[print version number]' \ - '1:interval:_guard "[0-9]#" "interval"' \ - '2:count:_guard "[0-9]#" "count"' && ret=0 - return ret + '1:interval' \ + '2:count' } _iostat() { - local ret=1 _arguments : \ '-c[display CPU utilization report]' \ '-d[display device utilization report]' \ '-T[only display global statistics for group_name]' \ - '-g[display statistics for a group of devices]:group name: _message "group name"' \ + '-g[display statistics for a group of devices]:group name' \ '-h[human readable device utilization report]' \ '-j[display persistent device name]' \ '(-m)-k[display statistics in kB/s]' \ '(-k)-m[display statistics in MB/s]' \ '-N[display registered device mapper names]' \ - '1:interval:_guard "[0-9]#" "interval"' \ - '2:count:_guard "[0-9]#" "count"' && ret=0 - return ret + '::device:_files -W /dev -g "*(-%)"' \ + ': :_guard "[0-9]#" "interval"' \ + ':count' } _cifsiostat() { - local ret=1 _arguments : \ '-h[human readable]' \ '(-m)-k[display statistics in kB/s]' \ '(-k)-m[display statistics in MB/s]' \ '-t[print timestamp for each report]' \ '-V[print version number]' \ - '1:interval:_guard "[0-9]#" "interval"' \ - '2:count:_guard "[0-9]#" "count"' && ret=0 - return ret + '1:interval' \ + '2:count' } _isag() { - local ret=1 _arguments : \ - '-p[Pathname to daily data files]:data files: _files -/' \ - '-c[Specify configuration file]:configuration file: _files' \ - '-ght[Specify height of the chart]:height: _message "height"' \ - '-gwd[Specify width of the chart]:width: _message "width"' && ret=0 - return ret + '-p[specify path to daily data files]:path:_files -/' \ + '-c[specify configuration file]:configuration file:_files' \ + '-ght[specify height of the chart]:height' \ + '-gwd[specify width of the chart]:width' } _sadf() { - local ret=1 line state context expl - typeset -A opt_args + local ret=1 # any options after `--' are for sar(1) if ! (( CURRENT > $words[(i)--] )); then _arguments : \ '-C[display comments in file]' \ '(-j -p -x)-d[output file in SQL format]' \ - '-e[set ending time of report]:ending time: _message "ending time in localtime(HH\:MM\:SS 24-hour format)"' \ + '-e[set ending time of report]:ending time (HH\:MM\:SS)' \ '-H[display only the header of the report]' \ '(-j -p -x)-h[print on a single line when used with -d]' \ '(-d -p -x)-j[output file in JSON]' \ '-P[restrict processor dependant statistics]:processor number(zero indexed) or ALL:(ALL)' \ '(-j -x -d)-p[print in format parsable by tools like awk]' \ - '-s[set starting time of report]:starting time: _message "starting time in localtime(HH\:MM\:SS 24-hour format)"' \ + '-s[set starting time of report]:starting time (HH\:MM\:SS)"' \ '(-t -U)-T[display timestamp in local time]' \ '(-T -U)-t[display timestamp in file\''s original localtime]' \ - '(-t -T)-U[display in seconds from epoch(UTC)]' \ + '(-t -T)-U[display in seconds since epoch (UTC)]' \ '-V[print version number]' \ '(-j -d -p)-x[output file in XML]' \ - '1:interval:_guard "[0-9]#" "interval"' \ - '2:count:_guard "[0-9]#" "count"' && ret=0 + '1:interval' \ + '2:count' \ + '3:data file:_files' && ret=0 else _arguments : '*::sar: _sar' && ret=0 fi @@ -85,20 +78,19 @@ _sadf() { } _sar() { - local ret=1 _arguments : \ '-A[equivalent to -bBdFHqrRSuvwWy -I SUM -I XALL -m ALL -n ALL -u ALL -P ALL]' \ '-B[report paging statistics]' \ '-b[report I/O and transfer rate statistics]' \ '-C[display comments from sadc]' \ '-d[report activity for each block device]' \ - '-e[set ending time of report]:ending time: _message "ending time (HH\:MM\:SS 24-hour format)"' \ + '-e[set ending time of report]:ending time (HH\:MM\:SS)' \ '-F[display statistics for mounted filesystems]' \ '-f[extract records from file]:record:_files' \ '-H[report hugepages utilization]' \ '-h[display help]' \ '*-I[report statistics for interrupts]:interrupts: _values -s "," interrupts 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 SUM ALL XALL' \ - '-i[select records as close as possible to interval]:interval: _message "interval"' \ + '-i[select records as close as possible to interval]:interval' \ '-j[display persistent device names]:type:(ID LABEL PATH UUID)' \ '-m[report power management statistics]:keywords: _values -s "," keywords CPU FAN FREQ IN TEMP USB ALL' \ '-n[report network statistics]:keywords: _values -s "," keywords DEV EDEV NFS NFSD SOCK IP EIP ICMP EICMP TCP ETCP UDP SOCK6 IP6 EIP6 ICMP6 EICMP6 UDP6 ALL' \ @@ -108,27 +100,25 @@ _sar() { '-R[report memory statistics]' \ '-r[report memory utilization statistics]' \ '-S[report swap space utilization]' \ - '-s[set starting time of report]:start time: _message "start time (HH\:MM\:SS 24-hour format)"' \ + '-s[set starting time of report]:start time (HH\:MM\:SS)' \ '-u[report CPU utilization]: :(ALL)' \ '-V[print version number]' \ '-v[report status of kernel tables]' \ '-W[report swapping statistics]' \ '-w[report task creation and system switching activity]' \ '-y[report TTY device activity]' \ - '1:interval:_guard "[0-9]#" "interval"' \ - '2:count:_guard "[0-9]#" "count"' && ret=0 - return ret + '1:interval' \ + '2:count' } _pidstat() { - local ret=1 _arguments : \ - '-C[filter tasks by string]:task: _message "string or regex"' \ + '-C[filter tasks by string]:task filter' \ '-d[report I/O statistics]' \ '-h[display on horizontally]' \ '-I[divide CPU usage by number of processors]' \ '-l[display process name along with arguments]' \ - '-p[select pid]:pid: _pids' \ + '-p[select pid]:pid: _sequence _pids' \ '-r[report page faults and memory]' \ '-s[report stack utilization]' \ '-T[specifies what to monitor]:type:(TASK CHILD ALL)' \ @@ -137,14 +127,13 @@ _pidstat() { '-u[report cpu utilization]' \ '-V[print version number]' \ '-v[display values from kernel table]' \ - '-w[report task switching activity]' && ret=0 - return ret + '-w[report task switching activity]' \ + ':interval' ':count' } _sysstat() { - local ret=1 - _call_function ret _$service - return ret -} + local ret + _call_function ret _$service && return ret +} _sysstat "$@" diff --git a/Completion/Mandriva/Command/_rebootin b/Completion/Mandriva/Command/_rebootin index 1b69609f3..3f30b2591 100644 --- a/Completion/Mandriva/Command/_rebootin +++ b/Completion/Mandriva/Command/_rebootin @@ -1,27 +1,29 @@ #compdef rebootin +local context state line expl +typeset -A opt_args local loader=$(sudo detectloader -q) -_arguments -C -s \ +_arguments -s \ '-n[no immediate reboot just set the flags for next reboot]' \ '-f[create a /fastboot file to reboot in fastboot mode]' \ '*::arguments:->loader_entry' -local expl case $state in - loader_entry) - case $loader in - GRUB) - if [ -r /boot/grub/menu.lst ];then - compadd ${${(M)${(f)"$(</boot/grub/menu.lst)"}##title *}#title } - fi - ;; - LILO) - if [ -r /etc/lilo.conf ];then - compadd $(awk -F= '{ if ($0 ~ /label=/) print $2 }' /etc/lilo.conf) - fi - ;; - *) - ;; - esac + loader_entry) + case $loader in + GRUB) + if [ -r /boot/grub/menu.lst ]; then + _wanted -C $context entries expl entry \ + compadd ${${(M)${(f)"$(</boot/grub/menu.lst)"}##title *}#title } + fi + ;; + LILO) + if [ -r /etc/lilo.conf ]; then + _wanted -C $context entries expl entry \ + compadd $(awk -F= '{ if ($0 ~ /label=/) print $2 }' /etc/lilo.conf) + fi + ;; + esac + ;; esac diff --git a/Completion/Mandriva/Command/_urpmi b/Completion/Mandriva/Command/_urpmi index 2468b2318..7951e6a9f 100644 --- a/Completion/Mandriva/Command/_urpmi +++ b/Completion/Mandriva/Command/_urpmi @@ -1,24 +1,8 @@ #compdef urpme urpmi urpmi.addmedia urpmi.removemedia urpmi.update urpmq urpmf parsehdlist _urpmi_media() { - local ret=1 single=0 - local -a all_sources opts - - if [[ $1 = -s ]]; then - single=1 - shift - fi - # TODO should we probe for active media only? - all_sources=( ${(f)"$(urpmq --list-media 2> /dev/null)"} ) - - if (( single )); then - compadd "$expl[@]" -a all_sources && ret=0 - else - _values -s , 'urpmi media' "$all_sources[@]" && ret=0 - fi - - return $ret + compadd "$@" - ${(f)"$(urpmq --list-media 2> /dev/null)"} } _urpmi_rpms() { @@ -40,7 +24,7 @@ _urpmi_rpms() { _requested files expl '(S)RPM file' \ _files -g '*.(#i)rpm(-.)' && ret=0 - + (( ret )) || break done @@ -65,12 +49,12 @@ _urpmi_media_url() { fi fi - return $ret + return ret } _urpme_package() { local -a _rpms - _rpms=( $(_call_program packages rpm -qa 2>/dev/null) ) + _rpms=( $(_call_program packages rpm -qa) ) compadd "$@" -a _rpms } @@ -80,12 +64,11 @@ _urpmi_parallel_alias() { } _urpmi() { - local state context line ret=1 help="--help -h" - - local -a opts_help opts_net opts_verbose opts_inst_rem opts_search opts_media + local ret=1 help="--help -h" + local -a opts_help opts_net opts_verbose opts_inst_rem opts_search opts_media opts_help=( - "($help : -)"{--help,-h}"[print usage information]" + "(: -)"{--help,-h}"[print usage information]" ) opts_net=( @@ -116,10 +99,10 @@ _urpmi() { ) opts_media=( - "($help)--excludemedia[do not use the given media]:urpmi media: _urpmi_media" - "($help --update --use-distrib)--media[use only the media listed by comma]:urpmi media: _urpmi_media" - "($help)--searchmedia[use only the given media to search requested (or updated) packages]:urpmi media: _urpmi_media -s" - "($help)--sortmedia[sort media according to substrings separated by comma]:urpmi media: _urpmi_media" + "($help)--excludemedia[do not use the given media]:urpmi media:_sequence _urpmi_media" + "($help --update --use-distrib)--media[use only the media listed by comma]:urpmi media:_sequence _urpmi_media" + "($help)--searchmedia[use only the given media to search requested (or updated) packages]:urpmi media:_urpmi_media" + "($help)--sortmedia[sort media according to substrings separated by comma]:urpmi media:_sequence _urpmi_media" "($help)--synthesis[use the given synthesis instead of urpmi db]:synthesis file:_url" "($help --media --use-distrib)--update[use only update media]" "($help --media --update)--use-distrib[configure urpmi on the fly from a distrib tree]:installation media:_urpmi_media_url" @@ -132,7 +115,7 @@ _urpmi() { $opts_inst_rem \ "--auto[do not ask any question]" \ "-v[verbose]" \ - ": :_urpme_package" + ": :_urpme_package" && ret=0 ;; urpmi.addmedia ) _arguments -A '-*' \ @@ -165,7 +148,7 @@ _urpmi() { "($help :)-a[select all media]" \ "($help)-c[clean headers cache directory]" \ "($help)-y[fuzzy mathing on media names]" \ - "(-a)"{,\*}": : _urpmi_media" \ + "(-a)"{,\*}":media:_sequence _urpmi_media" \ && ret=0 ;; urpmi.update ) @@ -179,7 +162,7 @@ _urpmi() { "($help --update :)-a[select all non-removable media]" \ "($help)-c[clean /var/cache/urpmi/headers on exit]" \ "($help)*-f[force generation of hdlist files]" \ - "($help -a)"{,\*}": : _urpmi_media" \ + "($help -a)"{,\*}":media:_sequence _urpmi_media" \ && ret=0 ;; urpmi ) @@ -308,7 +291,7 @@ _urpmi() { ;; esac - return $ret + return ret } _urpmi "$@" diff --git a/Completion/Redhat/Command/_rpm b/Completion/Redhat/Command/_rpm index 83922b60c..b2157bd48 100644 --- a/Completion/Redhat/Command/_rpm +++ b/Completion/Redhat/Command/_rpm @@ -32,6 +32,8 @@ # complete a RPM package file name # package_or_file # the previous two together +# file_or_package +# an absolute path to any file (not a package file) or a package # tags # complete a tag name # capability @@ -66,7 +68,7 @@ _rpm () { {-g,--group}'[query packages in one of specified groups]' --fileid --hdrid --pkgid --tid --querybynumber '--triggeredby' - '--whatprovides' + '--whatprovides:*:provided file:->file_or_package' '--whatrequires' ) sopts=${selectopts%\[*}\ --specfile @@ -122,7 +124,7 @@ _rpm () { query) # --dump requires one of -{l,c,d} # --triggers requires --script - _arguments -s \ + _arguments -s -C \ \!{-q,--query} "${commonopts[@]}" "${selectopts[@]}" "${pathopts[@]}" \ "($sopts)--specfile[query specified spec file as if it were a package]" \ '(-i --info)'{-i,--info}'[display package information]' \ @@ -140,10 +142,10 @@ _rpm () { {--triggers,--triggerscripts}'[show trigger scripts]' && ret=0 ;; setattrs) - _arguments -s --set{perm,ugids} "${selectopts[@]}" && ret = 0 + _arguments -s -C --set{perm,ugids} "${selectopts[@]}" && ret=0 ;; verify) - _arguments -s \!-{y,V} \ + _arguments -s -C \!-{y,V} \ "${commonopts[@]}" "${selectopts[@]}" "${pathopts[@]}" \ --no{deps,files,scripts,digest,signature,linkto,md5,size,user,group,mtime,mode,rdev} && ret=0 ;; @@ -151,7 +153,7 @@ _rpm () { tmp=( '(--force)--oldpackage' ) ;& install) - _arguments -s \!-{i,U} "$tmp[@]" \ + _arguments -s -C \!-{i,U} "$tmp[@]" \ "${commonopts[@]}" "${pathopts[@]}" \ '--excludepath:file to exclude:_files -/' \ '--relocate:relocate:->relocate' \ @@ -165,7 +167,7 @@ _rpm () { '*:pkg file:->package_file' && ret=0 ;; uninstall) - _arguments -s \!-e \ + _arguments -s -C \!-e \ "${commonopts[@]}" "${pathopts[@]}" \ --{allmatches,justdb,repackage,test} \ --no{deps,scripts,preun,postun,trigger{s,un,postun}} \ @@ -177,7 +179,7 @@ _rpm () { build_t) (( $#tmp )) || tmp=( '*:tar file:_files -g "*.(#i)tar(.*|)(-.)"' ) - _arguments -s \ + _arguments -s -C \ "${commonopts[@]}" "${pathopts[@]}" \ --{short-circuit,clean,nobuild,rmsource,sign,test} \ '--target:specify a build target:->target'\ @@ -187,13 +189,13 @@ _rpm () { '--timecheck:time check (seconds):' "$tmp[1]" && ret=0 ;; sigcheck) - _arguments -s \!-K \ + _arguments -s -C \!-K \ "${commonopts[@]}" \ --no{gpg,pgp,md5,signature,digest} \ '*:package file:->package_file' && ret=0 ;; rebuild) - _arguments -s \ + _arguments -s -C \ "${commonopts[@]}" "${pathopts[@]}" \ '*:source package file:->package_file' && ret=0 ;; @@ -246,6 +248,13 @@ _rpm () { package_or_file) state=package_file ;; + file_or_package) + if [[ $PREFIX = /* ]]; then + _wanted files expl 'file' _files + else + state=package + fi + ;; package) if ( [[ ${+_rpms} -eq 0 ]] || _cache_invalid RPMs ) && ! _retrieve_cache RPMs; @@ -286,7 +295,7 @@ _rpm () { ;; capabilities) _wanted capabilities expl capability compadd \ - ${(f)"$(_call_program capabilities rpm -qa --queryformat '%\{requirename}\\n' 2>/dev/null)"} + ${(f)"$(_call_program capabilities rpm -qa --queryformat '%\{requirename}\\n' 2>/dev/null)"} && ret=0 ;; relocate) if compset -P '*='; then diff --git a/Completion/Redhat/Command/_yum b/Completion/Redhat/Command/_yum index ae63364e6..a6983283c 100644 --- a/Completion/Redhat/Command/_yum +++ b/Completion/Redhat/Command/_yum @@ -85,15 +85,14 @@ _yum() fi } -# Fills the installed pkg cache +# Fills the all pkg cache _yum_all_pkgs() { if ( [[ ${+_all_pkgs} -eq 0 ]] || _cache_invalid ALL ) && ! _retrieve_cache ALL; then - local prog="yum -C list all | sed 's/\s.*//' | grep '\.'" - _all_pkgs=( $(kages $prog 2>/dev/null) ) - _store_cache ALL _all_pkg + _all_pkgs=( $(yum -C list all | sed 's/\s.*//' | grep '\.' 2>/dev/null) ) + _store_cache ALL _all_pkgs fi } @@ -227,8 +226,9 @@ _yum_list_or_info() else local subcmd subcmd="${${listlist[(r)$words[2]:*]%%:*}}" - # Deal with any aliases + # offer packages selected by the subcommand case $subcmd in + all) _yum_all;; installed) _yum_erase;; available) _yum_install;; updates) _yum_update;; diff --git a/Completion/Solaris/Command/_beadm b/Completion/Solaris/Command/_beadm index 6e498bee3..8422653d8 100644 --- a/Completion/Solaris/Command/_beadm +++ b/Completion/Solaris/Command/_beadm @@ -1,76 +1,69 @@ #compdef beadm -_beadm() { - local context state line subcmds - typeset -A opt_args +local cmd expl args - subcmds=( activate create destroy list mount rename unmount ) +if (( CURRENT == 2 )); then + _wanted subcommands expl 'subcommand' compadd \ + activate create destroy list mount rename unmount + return +fi - if [[ $service == "beadm" ]]; then - _arguments -C -A "-*" \ - '*::command:->subcmd' && return 0 +cmd="$words[2]" +curcontext="${curcontext%:*}-$cmd:" +shift words +(( CURRENT-- )) - if (( CURRENT == 1 )); then - _wanted commands expl 'beadm subcommand' compadd -a subcmds - return - fi - service="$words[1]" - curcontext="${curcontext%:*}=$service:" - fi - - case $service in - (activate) - _arguments -A "-*" \ - ':BE name:_be_name' - ;; - - (create) - # TODO: Add support for -o, and for creating snapshots - _arguments -A "-*" \ - '-a[Activate new BE]' \ - '-d[Description]:' \ - '-e[Base BE]:BE name or snapshot:_be_name -t all' \ - '-p[Create new BE in specified ZFS pool]:ZFS pool:_zfs_pool' \ - ':new BE name:' - ;; - - (destroy) - _arguments -A "-*" \ - '-f[Unmount BE if necessary]' \ - "-F[Don't prompt for verification]" \ - ':BE or BE snapshot:_be_name' - ;; - - (list) - _arguments -A "-*" \ - '-a[List subordinate filesystems and snapshots]' \ - '-d[List subordinate filesystems]' \ - '-s[List snapshots]' \ - '-H[Parseable format]' \ - ':BE name:_be_name' - ;; - - (mount) - _arguments -A "-*" \ - ':BE name:_be_name' \ - ':mountpoint:_path_files -/' - ;; - - (rename) - _arguments -A "-*" \ - ':existing BE name:_be_name' \ - ':new BE name:' - ;; - - (unmount) - _arguments -A "-*" \ - '-f[Force unmount]' \ - ':BE name:_be_name' - ;; - - (*) - _message "unknown beadm subcommand: $service" - esac -} - -_beadm "$@" +case $cmd in + activate) + _wanted boot-environs expl 'boot environment' _be_name + ;; + create) + [[ $OSTYPE = solaris* ]] && args=( + '-a[activate new BE]' + '-d[description]:description' + '*-o[property]:zfs property' + '-p[create new BE in specified zfs pool]:zfs pool:_zfs_pool' + ) + _arguments -A "-*" $args \ + '-e[base BE]:BE name or snapshot:_be_name -t all' \ + ':new BE name:' + ;; + destroy) + [[ $OSTYPE = solaris* ]] && args=( + '-f[unmount BE if necessary]' + ) + _arguments -A "-*" \ + "-F[don't prompt for verification]" \ + ':BE or BE snapshot:_be_name' + ;; + list) + if [[ $OSTYPE = solaris* ]]; then + args=( '-d[list subordinate filesystems]' ) + elif [[ $OSTYPE = freebsd* ]]; then + args=( '-D[display space usage of boot environment]' ) + fi + _arguments -A "-*" \ + '-a[list subordinate filesystems and snapshots]' \ + '-s[list snapshots]' \ + '-H[parseable format]' \ + ':boot environment:_be_name' + ;; + mount) + _arguments -A "-*" \ + ':BE name:_be_name' \ + ':mountpoint:_path_files -/' + ;; + rename) + _arguments -A "-*" \ + ':existing boot environment name:_be_name' \ + ':new boot environment:' + ;; + u(n|)mount) + _arguments -A "-*" \ + '-f[force unmount]' \ + ':boot environment:_be_name' + ;; + *) + _message "unknown beadm subcommand: $service" + ;; +esac diff --git a/Completion/Solaris/Command/_gcore b/Completion/Solaris/Command/_gcore deleted file mode 100644 index d4ac9a03a..000000000 --- a/Completion/Solaris/Command/_gcore +++ /dev/null @@ -1,31 +0,0 @@ -#compdef gcore - -_gcore() { - local -a content - - content=( - "anon[anonymous private mappings]" - "ctf[CTF type information]" - "data[writable private file mappings]" - "dism[DISM mappings]" - "heap[process heap]" - "ism[ISM mappings]" - "rodata[read-only private file mappings]" - "shanon[anonymous shared mappings]" - "shfile[file-backed shared mappings]" - "shm[System V shared memory]" - "stack[process stack]" - "symtab[symbol table sections for loaded files]" - "text[readable and executable private file mappings]" - ) - - _arguments -s \ - '-p[use per-process core file repository]' \ - '-g[use global core file repository]' \ - '-F[force grabbing the target process]' \ - '-c[set core file content]:_values -s + "content" $content' \ - '-o[set core file base name]:' \ - '*:pids:_pids' -} - -_gcore "$@" diff --git a/Completion/Solaris/Command/_ps b/Completion/Solaris/Command/_ps deleted file mode 100644 index 5ae61832a..000000000 --- a/Completion/Solaris/Command/_ps +++ /dev/null @@ -1,77 +0,0 @@ -#compdef ps - -_ps() -{ - local -a o_opt - -o_opt=( - "user[user ID]" - "ruser[real user ID]" - "group[group ID]" - "rgroup[real group ID]" - "pid[process ID]" - "ppid[parent process ID]" - "pgid[process group ID]" - "pcpu[ratio of CPU time used recently to CPU time available]" - "vsz[total size of the process in virtual memory, in kilobytes]" - "nice[decimal value of the system scheduling priority of the process]" - "etime[elapsed time since the process was started]" - "time[cumulative CPU time of the process]" - "tty[name of the controlling terminal of the process]" - "comm[name of the command being executed]" - "args[command with all its arguments as a string]" - "f[flags associated with the process]" - "s[state of the process]" - "c[processor utilization for scheduling]" - "uid[effective user ID number]" - "ruid[real user ID number]" - "gid[effective group ID number]" - "rgid[real group ID numberu]" - "projid[project ID number]" - "project[project name]" - "zoneid[zone ID number]" - "zone[zone name]" - "sid[process ID of the session leader]" - "taskid[task ID of the process]" - "class[scheduling class]" - "pri[priority, higher number - higher priority]" - "opri[obsolete priority, lower number - higher priority]" - "lwp[lwd ID number]" - "nlwp[number of lwps in the process]" - "psr[number of the processor to which the process or lwp is bound]" - "pset[ID of the processor set to which the process or lwp is bound]" - "addr[memory address of the process]" - "osz[total size of the process in virtual memory, in pages]" - "wchan[address of an event for which the process is sleeping]" - "stime[starting time or date of the process]" - "rss[resident set size of the process, in kilobytes]" - "pmem[ratio of resident set size to physical memory on the machine, in %]" - "fname[first 8 bytes of base name of process's executable file]" - "ctid[contract ID number]" - "lgrp[home lgroup]" -) -_arguments \ - '-a[information about all processes most frequently requested]' \ - '-c[information in a format that reflects scheduler properties]' \ - '-d[information about all processes except session leaders]' \ - '-e[information about every process]' \ - '-f[full listing]' \ - '-g[only process data whose group leaders ID number(s) appears in grplist]:group leader ID list' \ - '-G[information for processes whose real group ID numbers are in gidlist]:real group ID list' \ - '-H[prints the home lgroup of the process]' \ - '-j[prints session ID and process group ID]' \ - '-l[long listing]' \ - '-L[information about each light weight process]' \ - '-o[specify output format]:property:_values -s , "property" $o_opt' \ - '-p[only process data whose process ID numbers are given in proclist]:process ID list' \ - '-P[Prints the number of the processor to which the process or lwp is bound]' \ - '-s[information on all session leaders whose IDs appear in sidlist]:session leader ID list' \ - '-t[lists only process data associated with term]:term' \ - '-u[only process data whose effective user ID number or login name is given in uidlist]:UID:_users' \ - '-U[information for processes whose real user ID numbers or login names are in uidlist]:UID:_users' \ - '-y[both RSS and SZ is reported in kilobytes, instead pages (used with -l)]' \ - '-z[lists only processes in the specified zones]:zone list' \ - '-Z[prints the name of the zone with which the process is associated]' -} - -_ps "$@" diff --git a/Completion/Solaris/Command/_ptree b/Completion/Solaris/Command/_ptree index 035614b59..754979c37 100644 --- a/Completion/Solaris/Command/_ptree +++ b/Completion/Solaris/Command/_ptree @@ -1,23 +1,7 @@ #compdef ptree -_ptree() { - local curcontext="$curcontext" context state line ret=1 - typeset -A opt_args - - _arguments -s \ - '-a[all processes]' \ - '-c[show contract memberships]' \ - '-z[show processes in zone]:zone:($(zoneadm list))' \ - '*:pid or user:->pidoruser' && ret=0 - - if [[ $ret -ne 0 ]]; then - _alternative \ - 'users:logged-in user:compadd ${$(who -q)\:#(users=*|\#)}' \ - 'pids:pid:_pids' - ret=$? - fi - - return $ret -} - -_ptree "$@" +_arguments -s \ + '-a[all processes]' \ + '-c[show contract memberships]' \ + '-z[show processes in zone]:zone:_zones' \ + '*: : _alternative "users:logged-in user:_users_on" "pids:pid:_pids"' diff --git a/Completion/Solaris/Type/_be_name b/Completion/Solaris/Type/_be_name index b25a8ff22..4b80c65f2 100644 --- a/Completion/Solaris/Type/_be_name +++ b/Completion/Solaris/Type/_be_name @@ -1,18 +1,13 @@ #autoload -local -a type be_names -local name uuid activate mtpt space policy created snap +local -a type be_names expl zparseopts -D -E -a type t+: -beadm list -H | while IFS=\; read name uuid active mtpt space policy created; do - be_names=( $be_names $name ) -done +be_names=( ${${(f)"$(_call_program boot-environs beadm list -H)"}%%;*} ) -if [[ -n $type[(r)all] ]]; then - beadm list -sH | while IFS=\; read name snap space policy created; do - be_names=( $be_names $snap ) - done -fi +[[ -n $type[(r)all] ]] && + be_names+=( ${${${(f)"$(_call_program boot-environs beadm list -sH)"}#*;}%%;*} ) -compadd "$@" - $be_names +_description boot-environs expl 'boot environment' +compadd "$@" "$expl[@]" -a be_names diff --git a/Completion/Solaris/Type/_zones b/Completion/Solaris/Type/_zones index 0c2d273a2..92064d2b8 100644 --- a/Completion/Solaris/Type/_zones +++ b/Completion/Solaris/Type/_zones @@ -1,13 +1,11 @@ #autoload -local -a type typearg -local zonelist +local -a type typearg expl zparseopts -D -E -a type t+: [[ -n $type[(r)c] ]] && typearg=-c [[ -n $type[(r)i] ]] && typearg=-i -zonelist=( ${="$(zoneadm list $typearg)"} ) - -compadd "$@" - $zonelist +_description zones expl zone +compadd "$@" "$expl[@]" - ${="$(_call_program zones /usr/sbin/zoneadm list $typearg)"} diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb index 2e36046c7..e687762d3 100644 --- a/Completion/Unix/Command/_adb +++ b/Completion/Unix/Command/_adb @@ -63,6 +63,7 @@ _adb() { "root" "usb" "tcpip" + "sideload" "ppp" ) diff --git a/Completion/Unix/Command/_arp b/Completion/Unix/Command/_arp index 64a8b8069..f340e979e 100644 --- a/Completion/Unix/Command/_arp +++ b/Completion/Unix/Command/_arp @@ -1,6 +1,6 @@ #compdef arp -local state line expl curcontext="$curcontext" +local state line expl curcontext="$curcontext" ret=1 local -a cmds cmds=(-a --display -d --delete -s --set -f --file) @@ -15,7 +15,9 @@ _arguments -C \ '(-H --hw-type -d --delete)'{-H,--hw-type}'[class of entries to check for]:class:(ether arcnet pronet ax25 netrom)' \ '(-n --numeric -d --delete -s --set -f --file)'{-n,--numeric}'[shows numerical addresses]' \ '(-v --verbose)'{-v,--verbose}'[be verbose]' \ - '(-a)1:host:->hostintable' + '(-a)1:host:->hostintable' && ret=0 [[ "$state" = hostintable ]] && - _wanted hosts expl 'host' compadd ${${${(f)"$(${words[1]} -an)"}##[ ?(]#}%%[ )]*} + _wanted hosts expl 'host' compadd ${${${(f)"$(${words[1]} -an)"}##[ ?(]#}%%[ )]*} && ret=0 + +return ret diff --git a/Completion/Unix/Command/_at b/Completion/Unix/Command/_at index 8734e6b55..b22589020 100644 --- a/Completion/Unix/Command/_at +++ b/Completion/Unix/Command/_at @@ -1,6 +1,6 @@ #compdef atrm atq at batch -local context state line expl +local context state line expl ret=1 typeset -A opt_args #todo (when extremely bored) make -l and -d do the atq and atrm completions @@ -8,12 +8,12 @@ case $service in atrm) _arguments \ '-V[print version number]' \ - '*:job number:->jobs' + '*:job number:->jobs' && ret=0 ;; atq) _arguments \ '-V[print version number]' \ - '-q[uses specified queue]:a-z+A-Z' + '-q[uses specified queue]:a-z+A-Z' && ret=0 ;; at|batch) _arguments \ @@ -29,11 +29,13 @@ at|batch) - atrm \ '-d[alias for atrm]' \ - show-job \ - '-c[cat specified jobs to stdout]:*:job number:->jobs' + '-c[cat specified jobs to stdout]:*:job number:->jobs' && ret=0 esac case $state in jobs) - _wanted job expl 'job number' compadd ${(M)${(f)"$(_call_program job atq)"}##<->} + _wanted -C $context jobs expl 'job number' compadd ${(M)${(f)"$(_call_program job atq)"}##<->} && ret=0 ;; esac + +return ret diff --git a/Completion/Unix/Command/_bittorrent b/Completion/Unix/Command/_bittorrent index f7da2047a..1f305a1c0 100644 --- a/Completion/Unix/Command/_bittorrent +++ b/Completion/Unix/Command/_bittorrent @@ -21,7 +21,7 @@ case $service in ;& btlaunchmanycurses) _arguments -s -S \ - '(--responsefile)--responsefile+[specify file for server response]:file:_files -g "*"'\ + '(--responsefile)--responsefile+[specify file for server response]:file:_files'\ "--url+[specify URL of torrent file]:URL:_urls"\ '(-i --ip)'{-i+,--ip+}'[specify ip address to report as]:ip address'\ "--bind+[specify ip to bind to instead of default]:ip:_bind_addresses"\ @@ -50,18 +50,18 @@ case $service in "--max_initiate+[specify peers needed before stopping initiating new connections]:peers:"\ "--report_hash_failures+[report hash failures to user]:enable:(0 1)"\ "--rarest_first_priority_cutoff+[specify peers which need to have a piece before other partials take priority over rarest first]:peers:"\ - ':torrent file:_files -g "*.torrent(-.)"' \ - && return 0 + ':torrent file:_files -g "*.torrent(-.)"' + return ;; # Next up are the torrent file manipulation programs. btshowmetainfo) - _files -g "*.torrent(-.)" && return 0 - ;; + _files -g "*.torrent(-.)" && return + ;; btrename) - _files -g '*.torrent(-.)' && return 0 + _files -g '*.torrent(-.)' && return ;; btmakemetafile) @@ -69,12 +69,12 @@ case $service in '--piece_size_pow2+[specify power of 2 to set the piece size to]:power:' \ "--comment+[specify human-readable comment to put in .torrent]:comment:"\ "--target+[specify target file for the torrent]:file:_files"\ - ':file:_files -g "*"' \ - && return 0; + ':file:_files -g "*"' + return ;; btreannounce) - _files -g '*.torrent(-.)' && return 0 + _files -g '*.torrent(-.)' && return ;; # Lastly the tracker. @@ -94,7 +94,7 @@ case $service in "--min_time_between_log_flushes+[specify minimum time between log flushes]:time (s):" \ "--allowed_dir+[specify directory having downloadable torrents]:directory:_files -/" \ "--parse_allowed_interval+[specify interval between reloading allowed_dir]:time (min):" \ - "--show_names+[display names from allowed dir]:enable:(0 1)"\ - && return 0 - ;; + "--show_names+[display names from allowed dir]:enable:(0 1)" + return + ;; esac diff --git a/Completion/Unix/Command/_bogofilter b/Completion/Unix/Command/_bogofilter index 44953cc71..ff36e83af 100644 --- a/Completion/Unix/Command/_bogofilter +++ b/Completion/Unix/Command/_bogofilter @@ -1,7 +1,5 @@ #compdef bogoutil bogotune bogofilter -local expl ret bogotokens - _bogoutil_caching_policy () { local -a oldp @@ -14,6 +12,7 @@ _bogoutil_caching_policy () { _bogoutil() { + local bogotokens expl ret=1 typeset -a _bogoutil_actions _bogoutil_actions=(-h --help -V --version -d --dump -l --load -u --upgrade -m -w -p -H --db-verify -r -R --db-prune --db-recover @@ -46,30 +45,27 @@ _bogoutil() { "($_bogoutil_actions)"'--db-remove-environment:database:_files -/' \ '--db_lk_max_locks[set max lock count]' \ '--db_lk_max_objects[set max object count]' \ - "($_bogoutil_actions)"'-h[help]' \ - "($_bogoutil_actions)"'--help' \ - "($_bogoutil_actions)"'-V[version]' \ - "($_bogoutil_actions)"'--version' \ + "($_bogoutil_actions)"{-h,--help}'[help]' \ + "($_bogoutil_actions)"{-V,--version}'[version]' \ '*:tokens:->tokens' && ret=0 zstyle -s ":completion:${curcontext}:" cache-policy update_policy if [[ -z "$update_policy" ]]; then zstyle ":completion:${curcontext}:" cache-policy _bogoutil_caching_policy fi - + case $state in (tokens) if ( [[ -z "$bogotokens" ]] || _cache_invalid bogotokens ) && ! _retrieve_cache bogotokens; then - bogotokens=(${${(f)"$(_call_program bogoutil bogoutil -d ~/.bogofilter/wordlist.db -c 50)"}%% *}) + bogotokens=(${${(f)"$(_call_program bogotokens bogoutil -d ~/.bogofilter/wordlist.db -c 50)"}%% *}) _store_cache bogotokens bogotokens - else - : fi - _wanted tokens expl "token" \ - compadd -a bogotokens + _wanted tokens expl "token" compadd -a bogotokens && ret=0 ;; esac + + return ret } case $service in diff --git a/Completion/Unix/Command/_bpython b/Completion/Unix/Command/_bpython index c51cc8c3c..233e032e6 100644 --- a/Completion/Unix/Command/_bpython +++ b/Completion/Unix/Command/_bpython @@ -13,10 +13,10 @@ all_opts=( ) urwid_opts=( - '(-r --reactor)'{-r,--reactor}'[use Twisted reactor instead of the event loop]:reactor:' + '(-r --reactor)'{-r,--reactor}'[use twisted reactor instead of the event loop]:reactor' '--help-reactors[display list of available Twisted reactors]' - '(-p --plugin)'{-p,--plugin}'[exectue a twistd plugin]:plugin:' - '(-s --server)'{-s,--server}'[run an eval server on the given port]:port:' + '(-p --plugin)'{-p,--plugin}'[execute a twisted plugin]:plugin' + '(-s --server)'{-s,--server}'[run an eval server on the given port]:port:_ports' ) gtk_opts=( @@ -26,19 +26,19 @@ gtk_opts=( case "$service" in bpython|bpython2|bpython3) _arguments \ - "$all_opts[@]" && return 0 + "$all_opts[@]" ;; bpython-urwid|bpython2-urwid|bpython3-urwid) _arguments \ "$all_opts[@]" \ - "$urwid_opts[@]" && return 0 + "$urwid_opts[@]" ;; bpython-gtk|bpython2-gtk|bpython3-gtk) _arguments \ "$all_opts[@]" \ - "$gtk_opts[@]" && return 0 + "$gtk_opts[@]" ;; esac diff --git a/Completion/Unix/Command/_bzr b/Completion/Unix/Command/_bzr index c28c2148e..28ebd145c 100644 --- a/Completion/Unix/Command/_bzr +++ b/Completion/Unix/Command/_bzr @@ -11,12 +11,12 @@ _arguments -C \ if (( ! $+_bzr_cmds )); then typeset -gH _bzr_cmds - _bzr_cmds=(${(f)"$(_call_program bzr bzr shell-complete)"}) + _bzr_cmds=(${(f)"$(_call_program subcommands bzr shell-complete)"}) fi if [[ $state != 'args' ]]; then - _describe -t subcommand 'subcommand' _bzr_cmds - return 0 + _describe -t subcommands 'subcommand' _bzr_cmds + return fi cmd="$words[1]" @@ -25,39 +25,35 @@ curcontext="${curcontext%:*:*}:bzr-$cmd:" (( $+functions[_bzr_unknownFiles] )) || _bzr_unknownFiles() { local fileList - fileList=(${(ps:\0:)"$(bzr ls --null --unknown -R)"}) + fileList=(${(ps:\0:)"$(_call_program files bzr ls --null --unknown -R)"}) compadd -af fileList - return 0 } (( $+functions[_bzr_unknownRoot] )) || _bzr_unknownRoot() { - local fileList - fileList=(${(ps:\0:)"$(bzr ls --null --from-root --unknown)"}) + local -a fileList + fileList=(${(ps:\0:)"$(_call_program files bzr ls --null --from-root --unknown)"}) compadd -af fileList - return 0 } (( $+functions[_bzr_versionedFiles] )) || _bzr_versionedFiles() { local fileList - fileList=(${(ps:\0:)"$(bzr ls --null --versioned -R)"}) + fileList=(${(ps:\0:)"$(_call_program files bzr ls --null --versioned -R)"}) compadd -af fileList - return 0 } (( $+functions[_bzr_modifiedFiles] )) || _bzr_modifiedFiles() { local fileList - fileList=(${(ps:\0:)"$(bzr status . --versioned --short | cut -b 5- | tr '\n' '\0')"}) + fileList=(${(ps:\0:)"$(_call_program files bzr status . --versioned --short | cut -b 5- | tr '\n' '\0')"}) compadd -af fileList - return 0 } (( $+functions[_bzr_completeParents] )) || _bzr_completeParents() { - local parentFile=$(bzr root 2>/dev/null)/.bzr/branch/parent - [[ -r $parentFile ]] && compadd -X "Completing parents" $(cat $parentFile) + local parentFile=$(_call_program parents bzr root)/.bzr/branch/parent + [[ -r $parentFile ]] && _wanted parents expl parent compadd -- $(<$parentFile) } args=( '(-)'{--help,-h}'[show help message]' ) @@ -99,7 +95,7 @@ case $cmd in '--lightweight[perform a lightweight checkout]' '(-r --revision)'{--revision=,-r}'[the revision to get]:rev:' ) - _bzr_completeParents + _bzr_completeParents && ret=0 ;; (rename|move|mv) @@ -194,7 +190,7 @@ case $cmd in '(-v --verbose)'{--verbose,-v}'[display more information]' '*:local repository:_files -/' ) - _bzr_completeParents + _bzr_completeParents && ret=0 ;; (missing) @@ -210,7 +206,7 @@ case $cmd in '(-v --verbose)'{--verbose,-v}'[display more information]' '*:local repository:_files -/' ) - _bzr_completeParents + _bzr_completeParents && ret=0 ;; (commit|checkin|ci) @@ -226,8 +222,19 @@ case $cmd in ) ;; +(shelve) + args+=( + '--destroy[Destroy removed changes instead of shelving them]' + '(-m --message)'{--message=,-m}'[shelve message]:message text:' + '--all[shelve all changes]' + '(-q --quiet)'{--quiet,-q}'[be quiet]' + '(-v --verbose)'{--verbose,-v}'[display more information]' + '*:modified files:_bzr_modifiedFiles' + ) + ;; + (bind|break-lock|reconcile) - _bzr_completeParents + _bzr_completeParents && ret=0 ;; (register-branch) @@ -240,7 +247,7 @@ case $cmd in '--link-bug=[the bug this branch fixes]:bug-ID:' '--product=[launchpad product short name to associate with the branch]:product:' ) - _bzr_completeParents + _bzr_completeParents && ret=0 ;; (remerge) @@ -249,7 +256,7 @@ case $cmd in '--reprocess[reprocess to reduce spurious conflicts]' '--show-base[show base revision text in conflicts]' ) - _bzr_completeParents + _bzr_completeParents && ret=0 ;; (conflicts|added|deleted|modified|unknowns|directories|ignored|unbind|nick|revno|version) @@ -322,7 +329,7 @@ case $cmd in '--show-base[show base revision text in conflicts]' '*:local repository:_files -/' ) - _bzr_completeParents + _bzr_completeParents && ret=0 ;; (ls) @@ -346,7 +353,7 @@ case $cmd in '(-v --verbose -q --quiet)'{--verbose,-v}'[display more information]' '*:local repository:_files -/' ) - _bzr_completeParents + _bzr_completeParents && ret=0 ;; (help) @@ -355,8 +362,8 @@ case $cmd in '*:subcmds:->cmds' ) _arguments -s "$args[@]" && ret=0 - _describe -t subcommand 'subcommand' _bzr_cmds - return 0 + _describe -t subcommands 'subcommand' _bzr_cmds && ret=0 + return ret ;; # Plugins @@ -380,7 +387,7 @@ case $cmd in '--remember[remember the specified location as a default]' '*:local repository:_files -/' ) - _bzr_completeParents + _bzr_completeParents && ret=0 ;; (clean-tree) @@ -409,10 +416,11 @@ case $cmd in ;; (*) - _message "unknown bzr command completion: $cmd" - return 1 + _default + return ;; esac _arguments -s "$args[@]" && ret=0 -return $ret + +return ret diff --git a/Completion/Unix/Command/_cabal b/Completion/Unix/Command/_cabal new file mode 100644 index 000000000..bd81cf261 --- /dev/null +++ b/Completion/Unix/Command/_cabal @@ -0,0 +1,9 @@ +#compdef cabal + +local -a subcmds + +subcmds=(${${${${${(f)"$(cabal --help)"}[(r)Commands:*,(r)For more information*]}[2,-2]}# }%% *}) + +_arguments \ + '1:subcmd:compadd -a subcmds' \ + ':other: _alternative "options:option:compadd -- $(cabal $words[2] --list-options)" "files:file:_files"' diff --git a/Completion/Unix/Command/_cdrdao b/Completion/Unix/Command/_cdrdao index 06b47c9b1..ad1bf4034 100644 --- a/Completion/Unix/Command/_cdrdao +++ b/Completion/Unix/Command/_cdrdao @@ -4,108 +4,85 @@ # Command completion and main loop {{{1 -_cdrdao_commands () { - local -a commands - - commands=( - 'show-toc:print out a summary of a TOC' - 'read-toc:create a TOC file based on a CD' - 'read-cd:create a TOC file and image file based on a CD' - 'read-cddb:add CD-TEXT data from a CDDB server to a TOC' - 'show-data:print out samples that would be written to CD' - 'read-test:check if data described in a TOC can be read from a CD' - 'disk-info:show information about a CD' - 'msinfo:generate mkisofs command for creating multi-session CD' - 'unlock:try to unlock a recorder after a failed run' - 'blank:blank a CD-RW' - 'simulate:simulate a write' - 'write:write a CD based on a TOC' - 'copy:copy a CD' - ) - - _describe -t commands 'cdrdao command' commands && ret=0 -} - _cdrdao () { - local curcontext=$curcontext ret=1 - - local context state line - typeset -A opt_args - _arguments \ - ':command:->command' \ - '*::options:->options' && ret=0 - case $state in - (command) - _cdrdao_commands - ;; - (options) - curcontext="${curcontext%:*:*}:cdrdao-$words[1]:" - _call_function ret _cdrdao-$words[1] - ;; - esac + local ret=1 + local -a commands + if (( CURRENT == 2 )); then + commands=( ${${${(M)${(f)"$(_call_program subcommands cdrdao 2>&1)"}:# *}// #- /:}#??} ) + _describe -t subcommands 'cdrdao command' commands && ret=0 + else + local cmd="${words[2]}" + local curcontext="${curcontext%:*:*}:cdrdao-$cmd:" + shift words + (( CURRENT-- )) + if ! _call_function ret _cdrdao-$cmd; then + _default && ret=0 + fi + fi + return ret } # Common arguments {{{1 -declare -ga tmpfile_args -tmpfile_args=( +declare -ga _cdrdao_tmpfile_args +_cdrdao_tmpfile_args=( '--tmpdir[directory to store temporary data in]:directory:_directories' - '--keep[do not remove temporary data when done]') - -declare -ga device_args -device_args=( - '--device[set SCSI address of the CD recorder]:device:__cdrdao-device' - '--driver[use given driver for the CD recorder]:driver:__cdrdao-drivers') + '--keep[do not remove temporary data when done]' +) # TODO: Gah! Fix a cddb server spec matcher -declare -ga cddb_args -cddb_args=( +declare -ga _cdrdao_cddb_args +_cdrdao_cddb_args=( '--cddb-servers[specify list of CDDB servers to use]:CDDB servers:' '--cddb-timeout[specify timeout in seconds for connections to CDDB servers]: :_guard "[[\:digit\:]]" timeout' - '--cddb-directory[directory where fetched CDDB records will be stored]:directory:_directories') + '--cddb-directory[directory where fetched CDDB records will be stored]:directory:_directories' +) -declare -g paranoiamode_arg= -paranoiamode_arg='--paranoia-mode[set correction mode for digital audio extraction]:mode:(("0\:no checking" "1\:perform overlapped reading to avoid jitter" "2\:like 1 but with checks of read audio data" "3\:like 2 but with scratch detection/repair (default)"))' +declare -g _cdrdao_paranoiamode_arg +_cdrdao_paranoiamode_arg='--paranoia-mode[set correction mode for digital audio extraction]:mode:(("0\:no checking" "1\:perform overlapped reading to avoid jitter" "2\:like 1 but with checks of read audio data" "3\:like 2 but with scratch detection/repair (default)"))' -declare -g fasttoc_arg= -fasttoc_arg='--fast-toc[skip pre-gap-length and index-mark extraction]' +declare -g _cdrdao_fasttoc_arg +_cdrdao_fasttoc_arg='--fast-toc[skip pre-gap-length and index-mark extraction]' -declare -g swap_arg= -swap_arg='--swap[swap the byte order of samples]' +declare -g _cdrdao_swap_arg +_cdrdao_swap_arg='--swap[swap the byte order of samples]' -declare -g reload_arg= -reload_arg='--reload[reload the disk if necessary]' +declare -g _cdrdao_reload_arg +_cdrdao_reload_arg='--reload[reload the disk if necessary]' -declare -g eject_arg= -eject_arg='--eject[eject CD after completed operation]' +declare -g _cdrdao_eject_arg +_cdrdao_eject_arg='--eject[eject CD after completed operation]' -declare -g speed_arg= -speed_arg='-speed[set writing speed]: :_guard "[[\:digit\:]]##" speed' +declare -g _cdrdao_speed_arg +_cdrdao_speed_arg='-speed[set writing speed]: :_guard "[[\:digit\:]]##" speed' -declare -ga common_args -common_args=( +declare -ga _cdrdao_common_args +_cdrdao_common_args=( '(*)'{-h,--help}'[display command/option summary]' '-v[set verbosity level]: :_guard "[[\:digit\:]]##" verbosity') -declare -ga common_toc_args -common_toc_args=( - $common_args +declare -ga _cdrdao_common_toc_args +_cdrdao_common_toc_args=( + $_cdrdao_common_args ':TOC file:_files -g "*.toc(-.)"') -declare -ga common_device_args -common_device_args=( - $common_args - $device_args) - -declare -ga common_toc_device_args -common_toc_device_args=( - $common_toc_args - $common_device_args - $force_arg) - -declare -ga common_read_args -common_read_args=( +declare -ga _cdrdao_common_device_args +_cdrdao_common_device_args=( + $_cdrdao_common_args + '--device[set SCSI address of the CD recorder]:device:__cdrdao-device' + '--driver[use given driver for the CD recorder]:driver:__cdrdao-drivers' +) + +declare -ga _cdrdao_common_toc_device_args +_cdrdao_common_toc_device_args=( + $_cdrdao_common_toc_args + $_cdrdao_common_device_args + '--force[force execution of operation]' +) + +declare -ga _cdrdao_common_read_args +_cdrdao_common_read_args=( '--rspeed[set reading speed]: :_guard "[[\:digit\:]]##" speed' '--session[specify what session to process on multi-session CDs]: :_guard "[[\:digit\:]]##" "session number"' '--read-subchan[set sub-channel reading-mode]:mode:(("rw\:de-interleaved and error corrected" "rw_raw\:not de-interleaved, not error-corrected, and L-EC data included"))' @@ -128,18 +105,18 @@ _cdrdao-toc-size () { __cdrdao-show-toc-or-toc-info-or-toc-size () { _arguments \ - $common_toc_args \ - $tmpfile_args && ret=0 + $_cdrdao_common_toc_args \ + $_cdrdao_tmpfile_args } _cdrdao-read-toc () { - __cdrdao-read-toc-or-read-cd \ - $fasttoc_arg + __cdrdao-read-toc-or-read-cd $_cdrdao_cddb_args } _cdrdao-read-cd () { __cdrdao-read-toc-or-read-cd \ - $paranoiamode_arg + $_cdrdao_paranoiamode_arg \ + $_cdrdao_cddb_args } __cdrdao-read-toc-or-read-cd () { @@ -148,30 +125,31 @@ __cdrdao-read-toc-or-read-cd () { __cdrdao-read-toc-or-read-cd-or-copy-dependent-args _arguments \ - $common_toc_device_args \ - $common_read_args \ - $dependent_args + $_cdrdao_common_toc_device_args \ + $_cdrdao_common_read_args \ + $dependent_args \ + $_cdrdao_fasttoc_arg \ '--datafile[set name of data file placed in TOC file]:file:_files' \ '--read-raw[read data in raw format from CD]' \ '--no-mode2-mixed[if MODE2_FORM1 or MODE2_FORM2, do not extract as MODE2_FORM_MIX]' \ - $* && ret=0 + "$@" && ret=0 } _cdrdao-read-cddb () { _arguments \ - $common_toc_args \ - $cddb_args && ret=0 + $_cdrdao_common_toc_args \ + $_cdrdao_cddb_args } _cdrdao-show-data () { _arguments \ - $common_toc_args \ - $swap_arg && ret=0 + $_cdrdao_common_toc_args \ + $_cdrdao_swap_arg } _cdrdao-read-test () { _arguments \ - $common_toc_args && ret=0 + $_cdrdao_common_toc_args } _cdrdao-disk-info () { @@ -180,13 +158,18 @@ _cdrdao-disk-info () { __cdrdao-disk-info-or-drive-info () { _arguments \ - $common_device_args && ret=0 + $_cdrdao_common_device_args +} + +_cdrdao-discid() { + _arguments $_cdrdao_common_device_args $_cdrdao_cddb_args \ + '--query-string[print out CDDB query only]' } _cdrdao-msinfo () { _arguments \ - $common_device_args \ - $reload_arg && ret=0 + $_cdrdao_common_device_args \ + $_cdrdao_reload_arg } _cdrdao-drive-info () { @@ -195,22 +178,22 @@ _cdrdao-drive-info () { _cdrdao-unlock () { _arguments \ - $common_device_args \ - $reload_arg \ - $eject_arg && ret=0 + $_cdrdao_common_device_args \ + $_cdrdao_reload_arg \ + $_cdrdao_eject_arg } _cdrdao-blank () { _arguments \ - $common_device_args \ - $speed_arg \ + $_cdrdao_common_device_args \ + $_cdrdao_speed_arg \ '--blank-mode[set the blanking mode]:blanking mode:(("full\:completely erase data" "minimal\:only dereference data"))' \ - $eject_arg && ret=0 + $_cdrdao_eject_arg } _cdrdao-scanbus () { _arguments \ - $common_args && ret=0 + $_cdrdao_common_args } _cdrdao-simulate () { @@ -218,26 +201,26 @@ _cdrdao-simulate () { } __cdrdao-simulate-or-write () { - local capacity_arg= - + local _cdrdao_capacity_arg= + if (( $words[(I)--full-burn] )); then - capacity_arg='--capacity[set disk capacity for --full-burn]: :_guard "[[\:digit\:]]" minutes' + _cdrdao_capacity_arg='--capacity[set disk capacity for --full-burn]: :_guard "[[\:digit\:]]" minutes' fi _arguments \ - $common_toc_device_args \ - $speed_arg \ + $_cdrdao_common_toc_device_args \ + $_cdrdao_speed_arg \ '--multi[do not close the session after successful write]' \ '--overburn[allow overburing of medium]' \ '--full-burn[force burning to the outer disk edge]' \ - $capacity_arg \ - $eject_arg \ - $swap_arg \ + $_cdrdao_capacity_arg \ + $_cdrdao_eject_arg \ + $_cdrdao_swap_arg \ '--buffers[set fifo buffer size]: :_guard "[[\:digit\:]]" size' \ - $reload_arg \ - $tmpfile_args \ + $_cdrdao_reload_arg \ + $_cdrdao_tmpfile_args \ '-n[do not pause before writing]' \ - $* && ret=0 + $* } _cdrdao-write () { @@ -254,24 +237,24 @@ __cdrdao-read-toc-or-read-cd-or-copy-dependent-args () { fi if (( words[(I)--with-cddb] )); then - dependent_args+=$cddb_args + dependent_args+=$_cdrdao_cddb_args fi } _cdrdao-copy () { - local -ga dependent_args + local -a dependent_args __cdrdao-read-toc-or-read-cd-or-copy-dependent-args _cdrdao-write \ - $dependent_args - $common_read_args + $dependent_args \ + $_cdrdao_common_read_args \ '--source-device[set SCSI address of the CD reader]:device:__cdrdao-device' \ '--source-driver[use given driver for the CD reader]:driver:__cdrdao-drivers' \ '--on-the-fly[perform on-the-fly copy of CD (no image created)]' \ - $fasttoc_arg \ + $_cdrdao_fasttoc_arg \ '--keepimage[do not remove generated image when done]' \ - $paranoiamode_arg && ret=0 + $_cdrdao_paranoiamode_arg } # Type completion {{{1 @@ -280,24 +263,21 @@ __cdrdao-device () { # Use cdrdao scanbus and also check what OS we're running under and provide # additional stuff, like devices (/dev/sg0) local -a devices + devices=(${${(f)"$(_call_program devices cdrdao scanbus -v 0 2>&1)"}%% :*}) - devices=(${(f)"$(_call_program devices cdrdao scanbus -v 0 2>/dev/null)"}) - if (( ${#pipestatus:#0} > 0 )); then - return 1 - fi - - _wanted devices expl 'device' compadd - $devices + _wanted devices expl 'device' compadd -a devices } __cdrdao-drivers () { - local -a drivers - - drivers=(${(f)"$(_call_program drivers cut -d'|' -f4 /usr/share/cdrdao/drivers -s 2>/dev/null | sort -u)"}) - if (( ${#pipestatus:#0} > 0 )); then - return 1 + local suf + local -Ua drivers + drivers=(${(f)"$(_call_program drivers cut -d'\|' -f4 /usr/share/cdrdao/drivers -s)"}) + if compset -P \*:; then + _message -e options option + else + compset -S :\* || suf=-qS: + _wanted drivers expl 'driver' compadd $suf -a drivers fi - - _wanted drivers expl 'driver' compadd -qS: - $drivers } # }}}1 diff --git a/Completion/Unix/Command/_chmod b/Completion/Unix/Command/_chmod index 5d3cb2c78..85e6df1ae 100644 --- a/Completion/Unix/Command/_chmod +++ b/Completion/Unix/Command/_chmod @@ -1,34 +1,52 @@ -#compdef chmod +#compdef chmod gchmod local curcontext="$curcontext" state line expl ret=1 local -a args privs -args=( '*:file:->files' ) -(( $+words[(r)--reference*] )) || args+=( '1:mode:->mode' ) +args=( '*:file:->files' '1:mode:->mode' ) if _pick_variant gnu=Free\ Soft unix --version; then args+=( '(-v --verbose -c --changes)'{-c,--changes}'[report changes made]' '(-v --verbose -c --changes)'{-v,--verbose}'[output a diagnostic for every file processed]' '(-f --silent --quiet)'{-f,--silent,--quiet}'[suppress most error messages]' - '--reference=[copy permissions of specified file]:file:_files' + '(--no-preserve-root)--preserve-root[fail to operate recursively on /]' + "(--preserve-root)--no-preserve-root[don't treat / specially (default)]" + '(1)--reference=[copy permissions of specified file]:file:_files' '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]' '(- : *)--help[display help information]' '(- : *)--version[display version information]' ) - privs=( - 'X[execute only if executable to another]' - "u[owner's current permissions]" - "g[group's current permissions]" - "o[other's current permissions]" - ) else - # based on $OSTYPE = solaris2.8 args+=( '-f[suppress most error messages]' '-R[change files and directories recursively]' ) - privs=( 'l[mandatory locking]' ) + case $OSTYPE in + freebsd*|dragonfly*|darwin*) + args+=( '-v[output a diagnostic for every file processed]') + ;| + freebsd*|netbsd*|darwin*|dragonfly*) + args+=( "-h[operate on symlinks them self]" ) + ;| + freebsd*|openbsd*|netbsd*|darwin*|dragonfly*) + args+=( + '(-H -L -P)-L[follow all symlinks]' + '(-H -L -P)-H[follow symlinks on the command line]' + '(-H -L -P)-P[do not follow symlinks (default)]' + ) + ;| + darwin*) + args+=( + '(1)-C[returns false if any of the named files have ACLs]' + '(1)-N[remove ACLs from specified files]' + '(1)-E[read ACL info from stdin as a sequential list of ACEs]' + '(1)-i[removes inherited bit from all entries in named files ACLs]' + '(1)-I[removes all inherited entries from named files ACLs]' + ) + ;; + solaris*) privs=( 'l[mandatory locking]' ) ;; + esac fi _arguments -C -s "$args[@]" && ret=0 @@ -43,13 +61,17 @@ case "$state" in _values -S '' privilege \ 'r[read]' 'w[write]' 'x[execute]' \ 's[set uid/gid]' 't[sticky]' \ + 'X[execute only if directory or executable to another]' \ + "u[owner's current permissions]" \ + "g[group's current permissions]" \ + "o[other's current permissions]" \ "$privs[@]" && ret=0 else suf=( -S '' ) compset -P '*' _alternative -O suf \ 'who:who:((u\:user g\:group a\:all o\:others))' \ - 'operators:operator:(+ - =)' + 'operators:operator:(+ - =)' && ret=0 fi ;; files) diff --git a/Completion/Unix/Command/_chown b/Completion/Unix/Command/_chown index b4539315d..641b5a773 100644 --- a/Completion/Unix/Command/_chown +++ b/Completion/Unix/Command/_chown @@ -1,29 +1,42 @@ -#compdef chown chgrp +#compdef chown chgrp zf_chown=chown zf_chgrp=chgrp local curcontext="$curcontext" state line expl ret=1 -local suf usr grp req deref args +local suf usr grp req deref pattern arg args if _pick_variant gnu=Free\ Soft unix --version; then args=( '(-c --changes -v --verbose)'{-c,--changes}'[report each change made]' '(-c --changes -v --verbose)'{-v,--verbose}'[output info for every file processed]' '(-h --no-dereference)--dereference[dereference symlinks]' - '(-h --no-dereference --dereference)'{-h,--no-dereference}'[operate on symlinks them self]' + '(-h --no-dereference --dereference)'{-h,--no-dereference}'[operate on symlinks themselves]' '(-f --silent --quiet)'{-f,--silent,--quiet}"[don't report errors]" + '--preserve-root[fail to operate recursively on /]' '--reference=[copy ownership of specified file]:file:_files' '(-R --recursive)'{-R,--recursive}'[change files and directories recursively]' + '(-H -L -P)-L[follow all symlinks]' + '(-H -L -P)-H[follow symlinks on the command line]' + '(-H -L -P)-P[do not follow symlinks (default)]' '(- : *)--help[display help information]' '(- : *)--version[display version information]' ) [[ $service = chown ]] && args+=( '--from=[restrict changes to files by current ownership]: :->owner' ) else - # based on $OSTYPE = solaris2.8 args=( "-f[don't report errors]" "-h[operate on symlinks them self]" '-R[change files and directories recursively]' + '(-H -L -P)-L[follow all symlinks]' + '(-H -L -P)-H[follow symlinks on the command line]' + '(-H -L -P)-P[do not follow symlinks (default)]' ) + for pattern arg in \ + 'freebsd*' "-x[don't traverse file systems]" \ + '(darwin|dragonfly|(free|net)bsd)*' '-v[output info for every file processed]' \ + 'solaris2.<11->' '-s[owner and/or group are Windows SID strings]' + do + [[ $OSTYPE = $~pattern ]] && args+=( $arg ) + done fi (( $+words[(r)--reference*] )) || args+=( '(--reference)1: :->owner' ) @@ -32,8 +45,8 @@ _arguments -C -s "$args[@]" '*:files:->files' && ret=0 case $state in owner) if [[ $service = chgrp ]] || compset -P '*[:.]'; then - if (( EGID && $+commands[groups] )); then # except for root - _wanted groups expl 'group' compadd $(groups) && return 0 + if (( EGID && $+commands[groups] && ! $+funcstack[(r)_sudo] )); then # except for root + _wanted groups expl 'group' compadd $(groups) && return 0 fi _groups && ret=0 else diff --git a/Completion/Unix/Command/_cmp b/Completion/Unix/Command/_cmp new file mode 100644 index 000000000..bcede8b0b --- /dev/null +++ b/Completion/Unix/Command/_cmp @@ -0,0 +1,33 @@ +#compdef cmp gcmp + +local args variant +_pick_variant -r variant gnu=GNU $OSTYPE --version + +case $variant in + gnu) + args=( + '(-b --print-bytes)'{-b,--print-bytes}'[print differing bytes]' + '(-i --ignore-initial)'{-i+,--ignore-initial}'[skip specified number of bytes]:bytes' + '(-l --verbose -s --silent --quiet)'{-l,--verbose}'[output all differences]' + '(-n --bytes)'{-n+,--bytes=}'[specify maximum bytes to compare]:bytes' + '(-s --quiet --silent -l --verbose)'{-s,--quiet,--silent}'[return status alone signifies differences]' + '(- *)'{-v,--version}'[display version information]' + '(- *)--help[display help information]' + ) + ;; + freebsd*|openbsd*) + args=( + "-h[don't follow symbolic links]" + '-x[hexadecimal output and zero based offset index]' + '-z[compare file sizes first]' + ) + ;& + *) + args+=( + '(-s)-l[output all differences]' + '(-l)-s[silent: return status alone signifies differences]' + ) + ;; +esac + +_arguments -s $args '1:file 1:_files' '2:file 2:_files' '::byte offset' '::byte offset' diff --git a/Completion/Unix/Command/_comm b/Completion/Unix/Command/_comm index e90c317f6..d1d835f6a 100644 --- a/Completion/Unix/Command/_comm +++ b/Completion/Unix/Command/_comm @@ -1,20 +1,27 @@ -#compdef comm +#compdef comm gcomm local -a args args=( - '-1[suppress lines unique to FILE1]' - '-2[suppress lines unique to FILE2]' + '-1[suppress lines unique to first file]' + '-2[suppress lines unique to second file]' '-3[suppress lines that appear in both files]' - '1:file1 to compare:_files' - '2:file2 to compare:_files' + '1:file to compare:_files' + '2:file to compare:_files' ) if _pick_variant gnu=GNU unix --version; then args+=( + '(--nocheck-order)--check-order[check input is correctly sorted]' + "(--check-order)--nocheck-order[don't check input is correctly sorted]" + '--output-delimiter=:delimiter' '(- : *)--version[display version information]' '(- : *)--help[display help information]' ) +elif [[ $OSTYPE = (freebsd|dragonfly|darwin)* ]]; then + args+=( '-i[case insensitive comparison of lines]' ) +elif [[ $OSTYPE = (openbsd|netbsd)* ]]; then + args+=( '-f[case insensitive comparison of lines]' ) fi _arguments -s $args diff --git a/Completion/Unix/Command/_cp b/Completion/Unix/Command/_cp index 5013f852c..4c4dea2e9 100644 --- a/Completion/Unix/Command/_cp +++ b/Completion/Unix/Command/_cp @@ -1,62 +1,65 @@ -#compdef cp +#compdef cp gcp if _pick_variant gnu=GNU unix --version; then _arguments -s -S \ - '(-a --archive)'{-a,--archive}'[same as -dR --preserve=all]' \ + '(-a --archive)'{-a,--archive}'[archive mode, same as -dR --preserve=all]' \ + "--attributes-only[don't copy file data, just attributes]" \ '(-b --backup)-b[backup]' \ - '(-b --backup)--backup=[backup]:method:(none off numbered t existing nil simple never)' \ + '(-b --backup)--backup=-[backup each destination file]::method:(none off numbered t existing nil simple never)' \ '--copy-contents[copy contents of special files when recursive]' \ '-d[same as --no-dereference --preserve=links]' \ '(-f --force)'{-f,--force}'[remove and retry for destinations that cannot be opened]' \ - '(-i --interactive)'{-i,--interactive}'[prompt before overwrite]' \ + '(-i --interactive -n --no-clobber)'{-i,--interactive}'[prompt before overwrite]' \ '-H[follow command-line symbolic links]' \ '(-l --link)'{-l,--link}'[link files instead of copying]' \ '(-L --dereference)'{-L,--dereference}'[always follow symbolic links]' \ - '(-n --no-clobber)'{-n,--no-clobber}'[do not overwrite an existing file]' \ + (-n --no-clobber -i --interactive){-n,--no-clobber}"[don't overwrite an existing file]" \ '(-P --no-dereference)'{-P,--no-dereference}'[never follow symbolic links]' \ '-p[same as --preserve=mode,ownership,timestamps]' \ - '--preserve=[preserve specified attributes]:attributes to preserve:_values -s , mode timestamps ownership links context xattr all' \ - '--no-preserve=[don'\''t preserve specified attributes]:attributes not to preserve:_values -s , mode timestamps ownership links context xattr all' \ + '--preserve=-[preserve specified attributes]:: :_values -s , attribute mode timestamps ownership links context xattr all' \ + "--no-preserve=[don't preserve specified attributes]: :_values -s , attribute mode timestamps ownership links context xattr all" \ '--parents[append source path to target directory]' \ '(-R -r --recursive)'{-R,-r,--recursive}'[copy directories recursively]' \ - '--reflink=[control clone/CoW copies]:when to perform a lightweight copy:(always auto)' \ + '--reflink=-[control clone/CoW copies]::when to perform a lightweight copy:(always auto)' \ '--remove-destination[remove each existing destination file before attempting to open it]' \ '--sparse=[control creation of sparse files]:when to create sparse files:(auto always never)' \ '--strip-trailing-slashes[remove any trailing slashes from each source argument]' \ '(-s --symbolic-link)'{-s,--symbolic-link}'[make symbolic links instead of copies of non-directories]' \ - '(-S --suffix)'{-S,--suffix=}'[override the usual backup suffix]:backup suffix:' \ - '(-t --target-directory)'{-t,--target-directory=}'[copy all source arguments into target directory]:target directory:_files -/' \ + '(-S --suffix)'{-S+,--suffix=}'[override the usual backup suffix]:backup suffix' \ + '(-t --target-directory)'{-t+,--target-directory=}'[copy all source arguments into target directory]:target directory:_files -/' \ '(-T --no-target-directory)'{-T,--no-target-directory}'[treat DEST as a normal file]' \ '(-u --update)'{-u,--update}'[copy only when source is newer than destination or destination is missing]' \ '(-v --verbose)'{-v,--verbose}'[explain what is being done]' \ '(-x --one-file-system)'{-x,--one-file-system}'[stay on this file system]' \ - '--help' \ - '--version' \ + '(--context)-Z[set destination SELinux security context]' \ + '(-Z)--context=-[set destination SELinux security context]::context' \ + '(- *)--help' '(- *)--version' \ '*:file or directory:_files' - -elif [[ "$OSTYPE" == darwin* ]]; then - _arguments -s -S \ - '-R[copy directories recursively]' \ - '(-L -P)-H[with -R, follow symlinks on the command line]' \ - '(-H -P)-L[with -R, follow all symlinks]' \ - '(-H -L)-P[with -R, do not follow symlinks (default)]' \ - '(-i -n)-f[force overwriting existing file]' \ - '(-f -n)-i[confirm before overwriting existing file]' \ - '(-f -i)-n[do not overwrite existing file]' \ - '-a[same as -pRP]' \ - '-p[preserve timestamps, mode, owner, flags, ACLs, and Extended Attributes]' \ - '-v[show file names as they are copied]' \ - '-X[do not copy Extended Attributes or resource forks]' \ - '(-)*:file or directory:_files' - -else # assume POSIX - _arguments -s -S \ +else + local pattern arg args + args=( + '(-L -P)-H[follow symlinks on the command line in recursive mode]' + '(-H -P)-L[follow all symlinks in recursive mode]' + '(-H -L)-P[do not follow symlinks in recursive mode (default)]' + '(-i -n)-f[force overwriting existing file]' + '(-f -n)-i[confirm before overwriting existing file]' + '-p[preserve timestamps, mode, owner, flags, ACLs, and extended attributes]' '-R[copy directories recursively]' \ - '(-L -P)-H[with -R, follow symlinks on the command line]' \ - '(-H -P)-L[with -R, follow all symlinks]' \ - '(-H -L)-P[do not follow symlinks]' \ - '(-i)-f[force overwriting existing file]' \ - '(-f)-i[confirm before overwriting existing file]' \ - '-p[preserve timestamps, mode, and owner]' \ '(-)*:file or directory:_files' + ) + for pattern arg in \ + '(aix|hpux|irix|solaris)*' '-r[copy directories recursively]' \ + 'solaris2.<9->*' '-@[preserve extended attributes]' \ + 'solaris2.<11->*' '-/[preserve extended attributes and extended system attributes]' \ + '(darwin|dragonfly|freebsd)*' "(-f -i)-n[don't overwrite existing file]" \ + 'netbsd*' "-N[don't copy file flags]" \ + '(darwin|dragonfly|freebsd|netbsd)*' '-a[archive mode, same as -RpP]' \ + '(dragonfly|freebsd)*' '-l[link files instead of copying]' \ + '(darwin|dragonfly|freebsd|netbsd)*' '-v[show file names as they are copied]' \ + 'darwin*' "-X[don't copy extended attributes or resource forks]" \ + '(dragonfly|freebsd)*' "-x[don't traverse file systems]" + do + [[ $OSTYPE = $~pattern ]] && args+=( $arg ) + done + _arguments -s -S $args fi diff --git a/Completion/Unix/Command/_cpio b/Completion/Unix/Command/_cpio index 280a8930f..6b07a214a 100644 --- a/Completion/Unix/Command/_cpio +++ b/Completion/Unix/Command/_cpio @@ -1,17 +1,17 @@ #compdef cpio local args ig curcontext="$curcontext" state line -local expl ret +local expl ret=1 local fmts='(bar bin odc newc crc tar ustar hpbin hpodc)' _pick_variant -r ig gnu=GNU unix --version if (( CURRENT == 2 )); then - # Complete arguments + # Complete arguments args=('-o[create archive]' '-i[extract from archive]' '-p[run as filter on directory tree]') [[ $ig = gnu ]] && args=($args '--create[create archive]' - '--extract[extract from archive]' + '--extract[extract from archive]' '--pass-through[run as filter on directory tree]' '--help[show help text]' '--version[show version information]') else @@ -23,13 +23,13 @@ else "--format=:format type:$fmts" '--message=:message at end of volume:' '--null' '--reset-access-time' - '--verbose' '--dot' '--append' + '--verbose' '--dot' '--append' '--block-size=:block size in 512 byte units:' '--dereference' '--io-size=:block size in bytes' '--quiet' '--force-local' '--help' '--version') fi - args=($args + args+=( '-A[append files to archive]' '-B[block size 5120 bytes with special file]' '-C[set block size per record]:block size in bytes:(8192)' @@ -44,10 +44,10 @@ else if [[ $ig = gnu ]]; then args=('--file=:archive file:->afile' "--format=:format type:$fmts" - '--make-directories' '--nonmatching' + '--make-directories' '--nonmatching' '--preserve-modification-time' '--numeric' '--rename' '--list' '--swap-bytes' '--swap-halfwords' - '--dot' '--unconditional' '--verbose' + '--dot' '--unconditional' '--verbose' '--block-size=:block size in 512 byte units:' '--swap-halfwords' '--io-size=:block size in bytes:' @@ -58,7 +58,7 @@ else '--no-absolute-filenames' '--sparse' '--only-verify-crc' '--quiet' '--help' '--version') fi - args=($args + args+=( '-b[reverse bytes in word]' '-B[block size 5120 bytes with special file]' '-d[create directories as needed]' @@ -87,7 +87,7 @@ else '--owner=:user (and group) for files:->user' '--no-preserve-owner' '--sparse' '--help' '--version') fi - args=($args + args+=( '-d[create directories as needed]' '-l[link files instead of copying]' '-L[follow symbolic links]' @@ -98,12 +98,11 @@ else else return 1 fi - args=($args + args+=( '-a[reset access time of input files]' ) -fi +fi -ret=1 _arguments -C -s "$args[@]" && ret=0 if [[ $state = afile ]]; then @@ -121,12 +120,12 @@ if [[ $state = afile ]]; then fi elif [[ $state = user ]]; then if compset -P '*[:.]'; then - _groups + _groups && ret=0 else local suf=. [[ $OSTYPE = (solaris|hpux)* ]] && suf=: compset -S '.*' && unset suf - _users -S "$suf" -q + _users -S "$suf" -q && ret=0 fi fi diff --git a/Completion/Unix/Command/_cut b/Completion/Unix/Command/_cut index 1024c20a7..caf8f32b7 100644 --- a/Completion/Unix/Command/_cut +++ b/Completion/Unix/Command/_cut @@ -2,44 +2,41 @@ typeset -A _cut_args -if _pick_variant gnu="Free Soft" unix --version; then - case $LANG in - (de_DE.UTF-8) - _cut_args=( - bytes "nur diese Bytes ausgeben" - characters "nur diese Zeichen ausgeben" - delimiter "Delimiter anstelle von Tabulator als Trenner benutzen" - fields "nur diese Felder und alle Zeilen OHNE Trennzeichen ausgeben" - n "(ignoriert)" - complement $'das Komplement der Menge der gew\u00e4hlten Bytes, Zeichen oder Felder bilden' - only-delimited "keine Zeilen ausgeben, die keinen Trenner enthalten" - output-delimiter "Zeichenkette als Ausgabetrennzeichen benutzen" - help "diese Hilfe anzeigen und beenden" - version "Versionsinformation anzeigen und beenden" - ) - ;; - (*) - _cut_args=( - bytes "select only these bytes" - characters "select only these characters" - delimiter "use DELIM instead of TAB for field delimiter" - fields "select only these fields and lines without the delimiter character" - n "(ignored)" - complement "complement the set of selected bytes, characters or fields" - only-delimited "do not print lines not containing delimiters" - output-delimiter "use STRING as the output delimiter" - help "display this help and exit" - version "output version information and exit" - ) - ;; - esac +case $LANG in + (de_DE.UTF-8) + _cut_args=( + bytes "nur diese Bytes ausgeben" + characters "nur diese Zeichen ausgeben" + delimiter "Delimiter anstelle von Tabulator als Trenner benutzen" + fields "nur diese Felder und alle Zeilen OHNE Trennzeichen ausgeben" + complement $'das Komplement der Menge der gew\u00e4hlten Bytes, Zeichen oder Felder bilden' + only-delimited "keine Zeilen ausgeben, die keinen Trenner enthalten" + output-delimiter "Zeichenkette als Ausgabetrennzeichen benutzen" + help "diese Hilfe anzeigen und beenden" + version "Versionsinformation anzeigen und beenden" + ) + ;; + (*) + _cut_args=( + bytes "select only specified bytes" + characters "select only specified characters" + delimiter "use alternate field delimiter" + fields "select only specified fields" + complement "negate the set of selected bytes, characters or fields" + only-delimited "suppress lines with no delimiters" + output-delimiter "use specified string as the output delimiter" + help "display help information" + version "output version information" + ) + ;; +esac +if _pick_variant gnu="Free Soft" unix --version; then _arguments \ '(--bytes -b)'{--bytes=,-b+}'['$_cut_args[bytes]']:list' \ '(--characters -c)'{--characters=,-c+}'['$_cut_args[characters]']:list' \ '(--delimiter -d)'{--delimiter=,-d+}'['$_cut_args[delimiter]']:delimiter' \ '(--fields -f)'{--fields=,-f+}'['$_cut_args[fields]']:list' \ - '-n['$_cut_args[n]']' \ '--complement['$_cut_args[complement]']' \ '(--only-delimited -s)'{--only-delimited,-s}'['$_cut_args[only-delimited]']' \ '--output-delimiter=['$_cut_args[output-delimiter]']:delimiter' \ @@ -47,12 +44,15 @@ if _pick_variant gnu="Free Soft" unix --version; then '(- *)--version['$_cut_args[version]']' \ '*:file:_files' else - _arguments \ - '-b[list specifies byte positions]:list:' \ - '-c[list specifies character positions]:list:' \ - '-d[use alternate delimiter]:delimiter' \ - '-f[list specifies fields]:list:' \ - '-n[do not split multi-byte characters]' \ - '-s[suppress lines with no delimiters]' \ + case $OSTYPE in + freebsd*|dragonfly*) args+=( '(-d)-w[use whitespace as the delimiter]' ) ;; + esac + _arguments $args \ + "-b[${_cut_args[bytes]}]:list" \ + "-c[${_cut_args[characters]}]:list" \ + "(-w)-d[${_cut_args[delimiter]}]:delimiter" \ + "-f[${_cut_args[fields]}]:list" \ + "-n[do not split multi-byte characters]" \ + "-s[${_cut_args[only-delimited]}]" \ '*:file:_files' fi diff --git a/Completion/Unix/Command/_cvs b/Completion/Unix/Command/_cvs index 3c06e0481..31997ec09 100644 --- a/Completion/Unix/Command/_cvs +++ b/Completion/Unix/Command/_cvs @@ -704,15 +704,18 @@ _cvs_sub_modules() { _cvs_run() { local cvsroot="$1" dir="$2" shift 2 - local d=/tmp/zsh-cvs-work-$$ - mkdir $d >&/dev/null - cd $d - mkdir CVS >&/dev/null + local d=${TMPPREFIX:-/tmp/zsh}-cvs-work-$$ + rm -rf $d + mkdir $d && + ( + chmod 0700 $d && + builtin cd -q $d && + mkdir CVS >&/dev/null || return 1 print -r - "$cvsroot" > CVS/Root print "$dir" > CVS/Repository print D > CVS/Entries CVS_IGNORE_REMOTE_ROOT= cvs "$@" - cd $OLDPWD + ) rm -rf $d } diff --git a/Completion/Unix/Command/_date b/Completion/Unix/Command/_date index 7b1d3a7ab..e596ac038 100644 --- a/Completion/Unix/Command/_date +++ b/Completion/Unix/Command/_date @@ -1,4 +1,4 @@ -#compdef date +#compdef date gdate local -a args @@ -8,7 +8,7 @@ if _pick_variant gnu="Free Software Foundation" unix --version; then '-f[output dates specified in file]:file:_files' '-I-[iso-8601]:precision:(date hours minutes seconds)' '-r[reference]:file:_files' - '-R[rfc-2822]' + '-R[RFC2822 format]' '-s[set]:time string' '--rfc-3339=-[output date and time in RFC 3339 format]:output type:(date seconds ns)' -- @@ -20,26 +20,23 @@ else solaris*) args=( '-a:adjustment' ) ;; - freebsd*|darwin*) + freebsd*|darwin*|dragonfly*|netbsd*|openbsd*) args=( '-n[only set time on current machine]' '-d:daylight saving time value' '-j[do not try to set date]' - '-f:parsing format' '-r:seconds since epoch' '-t:minutes west of GMT' - '-v:adjustment value' ) + ;| + freebsd*) args+=( '-R[RFC2822 format]' ) ;| + freebsd*|dragonfly*|darwin*) + args+=( '-f:parsing format' '-v:adjustment value' ) ;; openbsd*) - args=( - '-n[only set time on current machine]' - '-d:daylight saving time value' - '-a[gradually skew]' - '-r:seconds since epoch' - '-t:minutes west of GMT' - ) - ;; + args+=( '-z[specify timezone for output]:time zone:_time_zone') + ;| + openbsd*|netbsd*) args=( '-a[gradually skew]' ) ;; esac fi diff --git a/Completion/Unix/Command/_df b/Completion/Unix/Command/_df index 892f91fa0..a98180a2c 100644 --- a/Completion/Unix/Command/_df +++ b/Completion/Unix/Command/_df @@ -1,6 +1,6 @@ #compdef df -local context state state_descr line args spec +local curcontext="$curcontext" state state_descr line args spec ret=1 local -A opt_args if _pick_variant gnu=GNU unix --version; then @@ -34,6 +34,7 @@ elif [[ "$OSTYPE" == (darwin|freebsd|dragonfly)* ]]; then '(-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)]' '-l[only display locally-mounted file systems]' '-n[use previously obtained statistics]' @@ -44,7 +45,7 @@ elif [[ "$OSTYPE" == (darwin|freebsd|dragonfly)* ]]; then (darwin*) args+=( "-T+$spec" -# '-t[same as -T (obsolete)]:file system type:->fslist' + "!-t+$spec" # obsolete ) ;; (freebsd*|dragonfly*) @@ -61,19 +62,15 @@ else ) fi -_arguments -s -S : $args && return 0 +_arguments -C -s -S : $args && ret=0 case "$state" in (fslist) - local -a fsys used pre disp expl - _file_systems -U -O fsys - pre=$IPREFIX - # offer 'no' only if at the beginning of the list - if ! compset -P '*,' && ! compset -P 'no'; then - disp=( 'no -- exclude file system types in the list' ) - _wanted list-prefix expl 'prefix to list' compadd -d disp 'no' - fi - used=( ${(s:,:)${${IPREFIX#$pre}#no}} ) - _wanted fsys-types expl "$state_descr" compadd -qS , -F used -a fsys + [[ ! -prefix *, ]] && ! compset -P 'no' && + _describe -t list-prefixes 'prefix to list' \ + '( no:exclude\ file\ system\ types\ in\ the\ list )' && ret=0 + _sequence -s , _file_systems && ret=0 ;; esac + +return ret diff --git a/Completion/Unix/Command/_django b/Completion/Unix/Command/_django index ac20409eb..029687696 100644 --- a/Completion/Unix/Command/_django +++ b/Completion/Unix/Command/_django @@ -1,26 +1,23 @@ #compdef django-admin.py django-admin manage.py -local ret=1 state +local curcontext="$curcontext" state line expl ret=1 -if [ "$service" = "manage.py" ] && [ ! -x ./manage.py ]; then - return 0 +if [[ "$service" = "manage.py" && ! -x ./manage.py ]]; then + _default + return fi declare -ga common_args common_args=( '--help[display help information]' '--version[display version information]' - '--pythonpath=[directory to add to the Python path]:directory:_directories' - '--settings=[Python path to settings module]:settings' + '--pythonpath=[directory to add to the Python path]:directory:_directories -W / -P /' + '--settings=[python path to settings module]:settings' '--traceback[print traceback on exception]' ) -_directories () { - _wanted directories expl directory _path_files -/ "$@" - -} - typeset -A opt_args -_arguments \ +_arguments -C \ $common_args \ ':subcommand:->subcommand' \ '*::options:->options' && ret=0 @@ -66,7 +63,7 @@ case $state in subcommands+=($cmd) fi done - + _describe -t subcommands 'django admin subcommand' subcommands && ret=0 ;; @@ -101,8 +98,8 @@ case $state in settings="${DJANGO_SETTINGS_MODULE}" else return 0 - fi - + fi + _wanted appname expl appname compadd - $(command \ sed -n "/INSTALLED_APPS\s*=\s*(/,/)/p" ${settings} | \ sed -n "s/^\s*'\(.*\.\)*\(.*\)'.*$/\2 /pg") @@ -205,7 +202,7 @@ case $state in ;; esac - _arguments $args && ret=0 + _arguments -C $args && ret=0 ;; esac diff --git a/Completion/Unix/Command/_du b/Completion/Unix/Command/_du index 9ae6e9cb3..d8871cd8d 100644 --- a/Completion/Unix/Command/_du +++ b/Completion/Unix/Command/_du @@ -1,7 +1,7 @@ -#compdef du +#compdef du gdu if _pick_variant gnu=Free\ Soft unix --version /dummy/no-such-file; then - local ret=1 + local context state line expl ret=1 _arguments -s \ '(-a --all -s --summarize)'{-a,--all}'[write counts for all files]' \ @@ -18,68 +18,61 @@ if _pick_variant gnu=Free\ Soft unix --version /dummy/no-such-file; then '(-l --count-links)'{-l,--count-links}'[count sizes many times if hard linked]' \ '(-L --dereference -H -D --dereference-args -P --no-dereference)'{-L,--dereference}'[dereference all symlinks]' \ '(-S --separate-dirs)'{-S,--separate-dirs}'[do not include size of subdirectories]' \ - '(-s --summarize --max-depth -a --all)'{-s,--summarize}'[only display total for each argument]' \ + '(-s --summarize --max-depth -a --all)'{-s,--summarize}'[only report total for each argument]' \ '(-x --one-file-system)'{-x,--one-file-system}'[skip directories on different filesystems]' \ '(-0 --null)'{-0,--null}'[end each output line with NUL instead of newline]' \ \*{-X+,--exclude-from=}'[exclude files matching any pattern in file]:file:_files' \ '*--exclude=[exclude files matching pattern]:pattern' \ '(-s --summarize)--max-depth=[maximum levels to recurse]:levels' \ - '--files0-from=[use NUL-terminated list of files from file]:file' \ + '--files0-from=[use NUL-terminated list of files from file]:file:_files' \ '--time-style=[show times using given style, +FORMAT for strftime formatted args]:style:->timestyle' \ - '--time=-[show time of last modification of any file in the directory]:property:->time' \ + '--time=-[show time of last modification of any file in the directory]:property:(atime access use ctime status)' \ + '(-t --threshold)'{-t+,--threshold=}'[report only entries for which size exceeds threshold]:threshold' \ '(* -)--help[display help information]' \ '(* -)--version[display version information]' \ '*:file:_files' && ret=0 case $state in - (time) - local -a property - property=(atime access use ctime status) - _wanted property expl property compadd -a property && ret=0 - ;; (timestyle) local -a style desc style=(full-iso long-iso iso +) desc=('full-iso' 'long-iso' 'iso' '+FORMAT like `date'\''') - _wanted -V style expl style compadd -d desc -a style && ret=0 - ;; + _wanted -C $context -V style expl style compadd -d desc -a style && ret=0 + ;; esac return ret -elif [[ "$OSTYPE" == darwin* ]]; then - _arguments -s -A "-*" \ - '(-H -L -P)-H[follow symlinks on the command line]' \ - '(-H -L -P)-L[follow all symlinks]' \ - '(-H -L -P)-P[do not follow symlinks (default)]' \ - '*-I+[ignore files/directories matching specified mask]:mask' \ - '(-a -s -d)-a[display entry also for files (not just directories) in file hierarchy]' \ - '(-a -s -d)-d+[display entry for directories up to specified depth]:depth' \ - '(-a -s -d)-s[display entry only for files/directories specified on the command line]' \ - '(-h -k -m -g)-h[human readable output]' \ - '(-h -k -m -g)-k[use block size of 1K-byte]' \ - '(-h -k -m -g)-m[use block size of 1M-byte]' \ - '(-h -k -m -g)-g[use block size of 1G-byte]' \ - '-c[display grand total]' \ - '-r[notify about unreadable files/directories]' \ - '-x[exclude directories on different file systems]' \ - '*:file:_files' - else - # based on $OSTYPE = solaris2.8 + local pattern arg args + args=( + '(-a -s -d)-a[report sizes for all files, not just directories]' + '(-H -L -P)-L[follow all symlinks]' + '(-a -s -d)-s[only report total for each argument]' + '(-h -m -g -B)-k[use block size of 1K-byte]' + '-r[notify about unreadable files/directories]' + ) local xdev='[skip directories on different filesystems]' - if [[ ${commands[$words[1]]:-$words[1]} = *xpg4* ]]; then - args=( -x$xdev ) - else - args=( -d$xdev - '-L[dereference symlinks]' - "(-a)-o[do not add child directories' usage to parent's total]" - ) - fi - _arguments -s "$args[@]" \ - '(-s -o)-a[write counts for all files]' \ - '-k[use block size of 1k]' \ - '-r[notify about unreadable files/directories]' \ - '(-a)-s[only display total for each argument]' \ - '*:file:_files' + for pattern arg in \ + 'freebsd*' '-A[apparent size instead of usage]' \ + '(darwin*|*bsd*|dragonfly*|solaris2.<10->)' '(-H -L -P)-H[follow symlinks on the command line]' \ + '(darwin|*bsd|dragonfly)*' '(-H -L -P)-P[do not follow symlinks (default)]' \ + '(darwin|dragonfly|freebsd)*' '*-I+[ignore files/directories matching specified mask]:mask' \ + '(darwin|*bsd|dragonfly)*' '(-a -s -d)-d+[display entry for directories up to specified depth]:depth' \ + '(darwin*|*bsd*|dragonfly*|solaris2.<10->)' '(-k -m -g -B)-h[human readable output]' \ + '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)' \ + '(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]' \ + 'solaris*' "(-a)-o[don't add child directories' usage to parent's total]" \ + 'freebsd<8->.*' '-t+[report only entries for which size exceeds threshold]:threshold' \ + 'solaris*' "-d$xdev" \ + '(darwin|*bsd|dragonfly|solaris)*' "-x$xdev" + do + [[ $OSTYPE = $~pattern ]] && args+=( $arg ) + done + _arguments -s -A "-*" $args fi diff --git a/Completion/Unix/Command/_ecasound b/Completion/Unix/Command/_ecasound index e31b072f9..7ad08d0e1 100644 --- a/Completion/Unix/Command/_ecasound +++ b/Completion/Unix/Command/_ecasound @@ -1,9 +1,9 @@ #compdef ecasound -local curcontext="$curcontext" state line expl +local curcontext="$curcontext" state line expl ret=1 typeset -A opt_args -_arguments \ +_arguments -C \ '-c[start in interactive mode]' \ '(-q)-d\:-[debug level]:debug level' \ '-D[print all debug information to stderr]' \ @@ -53,7 +53,7 @@ _arguments \ '*-eli\:-[LADSPA Plugin]: :->el' \ '*-gc\:-[time crop gate]: :->gc' \ '*-ge\:-[threshold gate]: :->ge' \ - && return 0 + ':input source:->io' && ret=0 case $state in filters) @@ -82,12 +82,12 @@ case $state in 'r[reverb effect]: :->etr' ;; emod) - _values -S : 'envelopme modulation' \ + _values -S : 'envelope modulation' \ 'b[pulse gate]: :->eemb' \ 'p[pulse gate (hz)]: :->eemp' \ 't[tremolo effect]: :->eemt' ;; -esac +esac && ret=0 case $state in b) @@ -173,12 +173,12 @@ case $state in typeset -A msgs local str msgs=( - eac 'amplification value (percent):channel' - eaw 'amplification value (percent):channel:max-clipped-samples' - ec 'compression rate (decibels):threshold (0.0-1.0)' - eca 'peak-level:release-time (seconds):fast compression rate (0.0-1.0):compression rate' - enm 'threshold-level:pre-hold-time (msec):attack-time (msec):post-hold-time (msec):release-time (msec)' - ezx 'left DC fix value:right CD fix value' + eac 'amplification value (percent):channel' + eaw 'amplification value (percent):channel:max-clipped-samples' + ec 'compression rate (decibels):threshold (0.0-1.0)' + eca 'peak-level:release-time (seconds):fast compression rate (0.0-1.0):compression rate' + enm 'threshold-level:pre-hold-time (msec):attack-time (msec):post-hold-time (msec):release-time (msec)' + ezx 'left DC fix value:right CD fix value' eemb 'pulse frequency (beats per minute):on time (msec)' eemp 'pulse frequency (hz):on time (percent)' eemt 'tremolo speed (beats per second):depth (percent)' @@ -206,5 +206,7 @@ case $state in str="${str#*:}" done _message "${str%%:*}" - ;; -esac + ;; +esac && ret=0 + +return ret diff --git a/Completion/Unix/Command/_elfdump b/Completion/Unix/Command/_elfdump new file mode 100644 index 000000000..ee92402d2 --- /dev/null +++ b/Completion/Unix/Command/_elfdump @@ -0,0 +1,47 @@ +#compdef elfdump + +local -a args + +_elf_file() { + [[ -x $REPLY || $REPLY = (core*|*.([ao]|so|elf)) ]] +} + +args=( + '-c[dump section header information]' + '-d[dump .dynamic section]' + '-e[dump file header]' + '-G[dump .got (global offset table) section]' + '-h[dump .hash section]' + '-i[dump .interp (interpreter) section]' + '-n[dump .note sections]' + '(-w)-p[dump program headers]' + '-r[dump relocation sections]' + '-s[dump symbol table sections]' + '(-p)-w[write contents of matched sections to file]:file:_files' +) + +case $OSTYPE in + solaris*) + args+=( + '-g[dump .group section]' + '-H[dump .SUNW_cap (capabilities) section]' + '-m[dump .SUNW_move section]' + '-S[dump symbol table sections sorted according to symbol sort sections]' + '-u[dump stack unwind/exceptions sections]' + '-v[dump .SUNW_version (versioning) sections]' + '-y[dump .SUNW_syminfo (symbol bindings) section]' + '-I[match sections by index]:index or range' + "-N[match sections by name]:section" + '-T[match sections by type]:type' + '-C[demangle C++ symbol names]' + '-k[calculate ELF checksum]' + '-l[show long section names without truncation]' + '-O[specify osabi to apply]:osabi' + '-P[use alternative section header]' + "*:elf file:_files -g '*(-.e:_elf_file:)'" + ) + ;; + freebsd*) args+=( '-a[dump all information]' ) ;; +esac + +_arguments -s $args diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg index 6a4ba234d..d68a094d4 100644 --- a/Completion/Unix/Command/_ffmpeg +++ b/Completion/Unix/Command/_ffmpeg @@ -1,6 +1,6 @@ #compdef ffmpeg -local context state line expl +local curcontext="$curcontext" state line expl typeset -A opt_args (( $+functions[_ffmpeg_presets] )) || _ffmpeg_presets() { @@ -33,14 +33,10 @@ typeset -A opt_args _wanted ffmpeg-formats expl 'force format' compadd -a formats } -(( $+functions[_ffmpeg_list_pix_fmts] )) || _ffmpeg_list_pix_fmts() { - echo - ${${${(M)${(f)"$(_call_program formats $words[1] -pix_fmts 2>/dev/null)"}:#[I.][O.][H.][P.][B.] [^=[:space:]]*}#* }%% *} -} - (( $+functions[_ffmpeg_pix_fmts] )) || _ffmpeg_pix_fmts() { local pix_fmts - pix_fmts=($(_ffmpeg_list_pix_fmts)) - _wanted ffmpeg-pix-fmts expl 'set pixel format' compadd -a pix_fmts + _wanted ffmpeg-pix-fmts expl 'pixel format' compadd "$@" - \ + ${${${(M)${(f)"$(_call_program formats $words[1] -pix_fmts 2>/dev/null)"}:#[I.][O.][H.][P.][B.] [^=[:space:]]*}#* }%% *} } (( $+functions[_ffmpeg_bsfs] )) || _ffmpeg_bsfs() { @@ -71,10 +67,10 @@ typeset -A _ffmpeg_flags local match mbegin mend integer ret=1 - if [[ $PREFIX = (#b)(*)[-+]([^-+]#) ]]; then + if [[ $PREFIX = (#b)(*)[-+]([^-+]#) ]]; then if [[ -n ${flag_options[(R)$match[2]]} ]]; then _ffmpeg_new_flag_options && ret=0 - fi + fi if [[ -n ${flag_options[(R)$match[2]?*]} ]]; then _ffmpeg_more_flag_options ${#match[1]} && ret=0 fi @@ -82,7 +78,7 @@ typeset -A _ffmpeg_flags _ffmpeg_flag_options && ret=0 fi - return $ret + return ret } (( $+functions[_ffmpeg_register_lastopt_values] )) || _ffmpeg_register_lastopt_values() { @@ -150,7 +146,7 @@ local -a _ffmpeg_argspecs elif [[ $lastopt == -pix_fmt ]]; then lastopt_takesargs=0 lastopt="*$lastopt" - lastopt+=": :_ffmpeg_pix_fmts" + lastopt+=":set pixel format:_ffmpeg_pix_fmts" elif [[ $example == bitstream_filter ]]; then lastopt_takesargs=0 lastopt+=": :_ffmpeg_bsfs" @@ -175,17 +171,17 @@ local -a _ffmpeg_argspecs [[ -n $lastopt ]] && _ffmpeg_register_lastopt_values } -_arguments -S \ +_arguments -C -S \ "${_ffmpeg_argspecs[@]}" \ '*:output file:_files' \ - && return 0 + && return [[ "$state" == "vfilters" ]] && _values -s , -S = 'video filters' \ 'aspect:set aspect ratio (rational number X\:Y or decimal number):' \ 'crop:crop input video (x\:y\:width\:height):' \ - 'format: :->format' \ - 'noformat: :->noformat' \ + 'format: :_sequence -s : _ffmpeg_pix_fmts' \ + 'noformat: :_sequence -s : _ffmpeg_pix_fmts' \ 'null' \ 'pad:add pads to the input image (width\:height\:x\:y\:color_string):' \ 'pixelaspect:set pixel aspect ratio (rational number X\:Y or decimal number):' \ @@ -196,15 +192,9 @@ _arguments -S \ 'buffer' \ 'nullsrc' \ 'nullsink' \ - && return 0 - -[[ "$state" == "format" ]] && - _values -s : -S = 'convert input video to one of the specified pixel formats' $(_ffmpeg_list_pix_fmts) && return 0 - -[[ "$state" == "noformat" ]] && - _values -s : -S = 'disable specified pixel formats by force' $(_ffmpeg_list_pix_fmts) && return 0 + && return [[ -n $state && -n $_ffmpeg_flags[$state] ]] && - _ffmpeg_flags $state && return 0 + _ffmpeg_flags $state && return return 1 diff --git a/Completion/Unix/Command/_find b/Completion/Unix/Command/_find index 33767c080..8f80e36cf 100644 --- a/Completion/Unix/Command/_find +++ b/Completion/Unix/Command/_find @@ -1,82 +1,145 @@ -#compdef find +#compdef find gfind -_arguments \ - '(- *)-help' '(-)--help' \ - '(- *)-version' '(-)--version' \ +local variant args + +_pick_variant -r variant gnu=GNU $OSTYPE -version + +case $variant in + solaris*) + args+=( + '*-'{n,}'cpio:device:_files' + '*-local' + ) + ;| + solaris*|darwin*) + args+=( '*-xattr' ) + ;| + solaris2.<10->|freebsd*|darwin*) + args+=( '*-acl' ) + ;| + solaris2.<11->|freebsd*|dragonfly*|darwin*|openbsd*|gnu) + args+=( + '*-amin:access time (minutes)' + '*-cmin:inode change time (minutes)' + '*-mmin:modification time (minutes)' + '*-iname:name pattern to match (case insensitive)' + '*-print0' + ) + ;| + netbsd*|freebsd*|dragonfly*|darwin*|gnu) + args+=( '(-H -L)-P[never follow symlinks]' ) + ;| + netbsd*|freebsd*|dragonfly*|openbsd*|darwin*|gnu) + args+=( '-d[depth first traversal]' ) + ;| + darwin*|freebsd*|gnu) + args+=( + '*-Bmin:birth time (minutes)' + '*-Bnewer:file to compare (birth time):_files' + '*-Btime:birth time (hours)' + ) + ;| + freebsd*|dragonfly*|darwin*|openbsd*|gnu) + args+=( + '*-anewer:file to compare (access time):_files' + '*-cnewer:file to compare (inode change time):_files' + '*-mnewer:file to compare (modification time):_files' + '*-maxdepth:maximum search depth' + '*-mindepth:minimum search depth' + '*-path:path pattern to search:' + ) + ;| + freebsd*|dragonfly*|darwin*|gnu) + args+=( + '*-delete' + '*-empty' + '*-execdir:program: _command_names -e:*\;::program arguments: _normal' + '*-gid:numeric group ID' + '*-uid:numeric user ID' + '*-noleaf' + '*-lname:link pattern to search' + '*-ilname:link pattern to search (case insensitive)' + '*-ipath:path pattern to search (case insensitive)' + '*-regex:regular expression to search' + '*-iregex:regular expression to search (case insensitive)' + '*-wholename:full path pattern to search' \ + '*-iwholename:full path pattern to search (case insensitive)' + '*-ignore_readdir_race' + '*-noignore_readdir_race' + '*-okdir:program: _command_names -e:*\;::program arguments: _normal' + '*-samefile:file to compare inode:_files' \ + '*-true' + '*-false' + '*-and' + '*-or' + '*-not' + ) + ;| + freebsd*|dragonfly*|gnu) args+=( '*-quit' ) ;| + netbsd*|freebsd*|dragonfly*|darwin*) + args+=( + '-E[use extended regular expressions with -regex/-iregex]' + '-X[warn if filename contains characters special to xargs]' + '-f[specify file hierarchy to traverse]:path:_directories' + '-s[traverse directories in sorted order]' + "-x[don't span filesystems]" + '*-flags:flags:_chflags' + ) + ;| + freebsd*|dragonfly*) args+=( '*-sparse' ) ;| + darwin*) args+=( '*-xattrname:name' ) ;| + gnu) + args+=( + '(- *)-help' '(-)--help' + '(- *)-version' '(-)--version' + '-D[print diagnostics]:debug option:(help tree search stat rates opt exec)' + '-O+[enable query optimisation]:level:(1 2 3)' + '*-daystart' + '-regextype:regexp syntax:(emacs posix-awk posix-basic posix-egrep posix-extended)' + '*-warn' + '*-nowarn' + '*-xautofs' + '*-used:access after inode change (days)' + '*-executable' + '*-readable' + '*-writable' + '*-xtype:file type:((b\:block\ special\ file c\:character\ special\ file d\:directory p\:named\ pipe f\:normal\ file l\:symbolic\ link s\:socket))' + '*-fls:output file:_files' + '*-fprint:output file:_files' + '*-fprint0:output file:_files' + '*-fprintf:output file:_files:output format' + '*-printf:output format' + ) + [[ $OSTYPE = linux-gnu ]] && args+=( '*-context:SELinux context' ) + ;; +esac + +_arguments $args \ '(-L -P)-H[only follow symlinks when resolving command-line arguments]' \ '(-H -P)-L[follow symlinks]' \ - '(-H -L)-P[never follow symlinks]' \ - '-D[print diagnostics]:deb option:(help tree search stat rates opt exec)' \ - '-O+[enable query optimisation]:level:(1 2 3)' \ - '*-daystart' \ - '*-d' '*-depth' \ + '*-atime:access time (days)' \ + '*-ctime:inode change time (days)' \ + '*-depth' \ + '*-exec:program: _command_names -e:*\;::program arguments: _normal' \ '*-follow' \ - '(-noignore_readdir_race)-ignore_readdir_race' \ - '*-maxdepth:maximum search depth' \ - '*-mindepth:minimum search depth' \ - '*-mount' \ - '(-ignore_readdir_race)-noignore_readdir_race' \ - '*-noleaf' \ - '-regextype:regexp syntax:(emacs posix-awk posix-basic posix-egrep posix-extended)' \ - '*-warn' \ - '*-nowarn' \ - '*-xdev' \ - '*-amin:access time (minutes):' \ - '*-cmin:inode change time (minutes):' \ - '*-mmin:modification time (minutes):' \ - '*-atime:access time (days):' \ - '*-ctime:inode change time (days):' \ - '*-mtime:modification time (days):' \ - '*-anewer:file to compare (access time):_files' \ - '*-cnewer:file to compare (inode change time):_files' \ - '*-newer:file to compare (modification time):_files' \ - '*-used:access after inode change (days):' \ - '*-empty' \ - '*-executable' \ - '*-false' \ '*-fstype:file system type:_file_systems' \ - '*-gid:numeric group ID:' \ '*-group:group:_groups' \ - '*-uid:numeric user ID:' \ - '*-user:user:_users' \ - '*-lname:link pattern to search:' \ - '*-ilname:link pattern to search (case insensitive):' \ - '*-name:name pattern to search:' \ - '*-iname:name pattern to search (case insensitive):' \ - '*-path:path pattern to search:' \ - '*-ipath:path pattern to search (case insensitive):' \ - '*-regex:regular expression to search:' \ - '*-iregex:regular expression to search (case insensitive):' \ - '*-wholename:full path pattern to search:' \ - '*-iwholename:full path pattern to search (case insensitive):' \ '*-inum:inode number:' \ '*-links:number of links:' \ - '*-nouser' \ + '*-ls' \ + '*-mount' \ + '*-mtime:modification time (days)' \ + '*-name:name pattern' \ + '*-newer:file to compare (modification time):_files' \ '*-nogroup' \ - '*-perm:file permission bits:' \ - '*-readable' \ - '*-writable' \ - '*-size:file size:' \ - '*-samefile:same inode as:_files' \ - '*-true' \ - '*-type:file type:((b\:block\ special\ file c\:character\ special\ file d\:directory p\:named\ pipe f\:normal\ file l\:symbolic\ link s\:socket))' \ - '*-xtype:file type:((b\:block\ special\ file c\:character\ special\ file d\:directory p\:named\ pipe f\:normal\ file l\:symbolic\ link s\:socket))' \ - '*-delete' \ - '*-exec:program: _command_names -e:*\;::program arguments: _normal' \ - '*-execdir:program: _command_names -e:*\;::program arguments: _normal' \ + '*-nouser' \ '*-ok:program: _command_names -e:*\;::program arguments: _normal' \ - '*-okdir:program: _command_names -e:*\;::program arguments: _normal' \ - '*-fls:output file:_files' \ - '*-fprint:output file:_files' \ - '*-fprint0:output file:_files' \ - '*-fprintf:output file:_files:output format:' \ + '*-perm:file permission bits' \ '*-print' \ - '*-print0' \ - '*-printf:output format:' \ '*-prune' \ - '*-quit' \ - '*-ls' \ - '*-and' '*-a' \ - '*-or' '*-o' \ - '*-not' \ + '*-size:file size (blocks)' \ + '*-type:file type:((b\:block\ special\ file c\:character\ special\ file d\:directory p\:named\ pipe f\:normal\ file l\:symbolic\ link s\:socket))' \ + '*-user:user:_users' \ + '*-xdev' \ + '*-a' '*-o' \ '*:directory:_files -/' diff --git a/Completion/Unix/Command/_fuser b/Completion/Unix/Command/_fuser index ba0f301ea..f497729fc 100644 --- a/Completion/Unix/Command/_fuser +++ b/Completion/Unix/Command/_fuser @@ -1,10 +1,18 @@ #compdef fuser -local -a args arg1 +local -a args argf variant typeset -A opt_args -if _pick_variant -c $words[1] psmisc='(#i)psmisc' unix -V; then +args=( + '-u[append the user name of the process owner to each PID]' + '(-f)-c[list all processes accessing files on the filesystem specified by name]' + '(-c)-f[list all processes accessing named files]' +) +argf=( '*:file:_files' ) +_pick_variant -r variant psmisc='(#i)psmisc' $OSTYPE -V +case $variant in + psmisc) (( $+functions[_fuser_services] )) || _fuser_services() { local expl suf ret=1 @@ -23,45 +31,51 @@ if _pick_variant -c $words[1] psmisc='(#i)psmisc' unix -V; then compset -S ',*' || suf=( -S ${${opt_args[-n]/?*/,}:-/} -r "/, \t\n\-" ) _ports $suf && ret=0 fi - + return ret } - _arguments \ - '(-s)-a[show all files specified on the command line]' \ - {-c,-m}'[list all processes accessing files on the filesystem specified by name]' \ - '-k[kill processes accessing the file]' \ - '-i[ask for confirmation before killing]' \ - '-l[list all known signal names]' \ - '-n[select name space]:namespace:(file udp tcp)' \ - '(-a)-s[silent operation]' \ - '-signal[send alternate signal with -k]:signal:_signals' \ - '-u[append the user name of the process owner to each PID]' \ - '-v[verbose mode]' \ - '-V[display version information]' \ - '-4[search only for IPv4 sockets]' \ - '-6[search only for IPv6 sockets]' \ - '*:name: _alternative "files:file:_files" "services:service:_fuser_services"' - -else - case $OSTYPE in - solaris2.9 ) - args=( - '-n[list only processes with non-blocking mandatory locks]' - '-s[send alternate signal with -k]:signal:_signals' - ) - ;; - sysv4 ) - (( $+words[(r)-k] )) && arg1=( ':name: _alternative signals\:signal\:_signals\ -p files:file:_files' ) - ;; - esac + args+=( + '(-s)-a[show all files specified on the command line]' \ + {-c,-m}'[list all processes accessing files on the filesystem specified by name]' \ + '-k[kill processes accessing the file]' \ + '-i[ask for confirmation before killing]' \ + '(-)-l[list all known signal names]' \ + '-n[select name space]:namespace:(file udp tcp)' \ + '(-a -u -v)-s[silent operation]' \ + '-v[verbose mode]' \ + '-V[display version information]' \ + '-4[search only for IPv4 sockets]' \ + '-6[search only for IPv6 sockets]' \ + ) + argf=( '*:name: _alternative "files:file:_files" "services:service:_fuser_services"' ) + [[ -prefix - && -z ${${words[1,CURRENT-1]}[(r)-[A-Z][A-Z]*]} ]] && + argf[1]+=' "signal:signals:_signals -P-"' + ;; + freebsd*|openbsd*|solaris2.<9->) + args+=( + '-s[send alternate signal]:signal:_signals' + '-k[send SIGKILL to each process]' + ) + ;| + openbsd*|freebsd*) + args+=( + '-M[extra values from specified core file]:core file:_files' + '-N[extract name list from specified system]:system' + ) + ;| + freebsd*) args+=( '-m[include mapped files]' ) ;; + solaris2.<9->) + args+=( + '-n[list only processes with non-blocking mandatory locks]' + ) + ;; + solaris2.<10->) + args+=( '-d[report device usage for all minor nodes bound to same device]' ) + ;; + sysv4 ) + (( $+words[(r)-k] )) && argf=( ':name: _alternative signals\:signal\:_signals\ -p files:file:_files' ) + ;; +esac - _arguments \ - '(-f)-c[list all processes accessing files on the filesystem specified by name]' \ - '(-c)-f[list all processes accessing named files]' \ - '-k[kill processes accessing the file]' \ - '-u[append the user name of the process owner to each PID]' \ - $args \ - $arg1 \ - '*:file:_files' -fi +_arguments -s $args $argf diff --git a/Completion/Unix/Command/_gcc b/Completion/Unix/Command/_gcc index c6bbabbe9..2c5ffdc8a 100644 --- a/Completion/Unix/Command/_gcc +++ b/Completion/Unix/Command/_gcc @@ -1,4 +1,4 @@ -#compdef gcc g++ cc c++ llvm-gcc llvm-g++ clang clang++ -value-,LDFLAGS,-default- -value-,CFLAGS,-default- -value-,CPPFLAGS,-default- +#compdef gcc g++ cc c++ llvm-gcc llvm-g++ clang clang++ -value-,LDFLAGS,-default- -value-,CFLAGS,-default- -value-,CXXFLAGS,-default- -value-,CPPFLAGS,-default- local curcontext="$curcontext" state line ret=1 expl args args2 march typeset -A opt_args @@ -13,7 +13,7 @@ if [[ "$service" = -value-* ]]; then args2=() fi else - args2=( '*:input file:_files -g "*.([cCmisSoak]|cc|cxx|ii|k[ih])(-.)"' ) + args2=( '*:input file:_files -g "*.([cCmisSoak]|cc|cpp|cxx|ii|k[ih])(-.)"' ) fi args=() diff --git a/Completion/Unix/Command/_gcore b/Completion/Unix/Command/_gcore new file mode 100644 index 000000000..4933ffee6 --- /dev/null +++ b/Completion/Unix/Command/_gcore @@ -0,0 +1,50 @@ +#compdef gcore + +case $OSTYPE in + solaris*) + local -a content + + content=( + 'anon[anonymous private mappings]' + 'ctf[CTF type information]' + 'data[writable private file mappings]' + 'dism[DISM mappings]' + 'heap[process heap]' + 'ism[ISM mappings]' + 'rodata[read-only private file mappings]' + 'shanon[anonymous shared mappings]' + 'shfile[file-backed shared mappings]' + 'shm[System V shared memory]' + 'stack[process stack]' + 'symtab[symbol table sections for loaded files]' + 'text[readable and executable private file mappings]' + ) + + _arguments -s \ + '(-c -g)-p[use per-process core file repository]' \ + '(-c -p)-g[use global core file repository]' \ + '-F[force grabbing the target process]' \ + '(-p -g)-c[set core file content]: :_values -s + "content" $content' \ + '-o[set core file base name]:file base name:_files' \ + '*:pid:_pids' + ;; + netbsd*) + _arguments \ + '-c+[write core file to specified file]:file:_files' \ + '*:pid:_pids' + ;; + freebsd*) + _arguments -s \ + '-c+[write core file to specified file]:file:_files' \ + '-f[dump all available segments]' \ + '-s[stop process while gathering image]' \ + '::executable:' \ + ':pid:_pids' + ;; + *) + # GNU GDB gcore + _arguments \ + '-o[set core file base name]:file base name:_files' \ + ':pid:_pids' + ;; +esac diff --git a/Completion/Unix/Command/_getent b/Completion/Unix/Command/_getent index 3ea148b71..b9aff6642 100755 --- a/Completion/Unix/Command/_getent +++ b/Completion/Unix/Command/_getent @@ -5,7 +5,7 @@ local services databases keys local -a args typeset -A opt_args -if _pick_variant -r is_gnu gnu='(GNU|EGLIBC)' unix --version; then +if _pick_variant -r is_gnu gnu='(GNU|EGLIBC|Gentoo)' unix --version; then args+=( '(- 1 *)'{-\?,--help}'[display help information]' '(- 1 *)--usage[display a short usage message]' diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index c4e386b15..979e3e76f 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -4,7 +4,7 @@ # # Say you got your own git sub-commands (git will run a program `git-foo' # when you run "git foo") and you want "git f<tab>" to complete that sub -# commands name for you. You can make that sub-command know to the completion +# commands name for you. You can make that sub-command known to the completion # via the user-command style: # # % zstyle ':completion:*:*:git:*' user-commands foo:'description for foo' @@ -20,17 +20,13 @@ # completion as well. Place such a function inside an autoloaded #compdef file # and you should be all set. You can add a description to such a function by # adding a line matching -# +# # #description DESCRIPTION # # as the second line in the file. See # Completion/Debian/Command/_git-buildpackage in the Zsh sources for an # example. # -# As this solution is so much better than the user-commands zstyle method, the -# zstyle method is now DEPRECATED. It will most likely be removed in the next -# major release of Zsh (5.0). -# # When _git does not know a given sub-command (say `bar'), it falls back to # completing file names for all arguments to that sub command. I.e.: # @@ -651,8 +647,8 @@ _git-commit () { # TODO: --interactive isn't explicitly listed in the documentation. _arguments -w -S -s \ '(-a --all --interactive -o --only -i --include *)'{-a,--all}'[stage all modified and deleted paths]' \ - '--fixup=[construct a commit message for use with rebase --autosquash]:' \ - '--squash=[construct a commit message for use with rebase --autosquash]:' \ + '--fixup=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_recent_commits' \ + '--squash=[construct a commit message for use with rebase --autosquash]:commit to be amended:__git_recent_commits' \ $reset_author_opt \ '( --porcelain --dry-run)--short[output dry run in short format]' \ '(--short --dry-run)--porcelain[output dry run in porcelain-ready format]' \ @@ -1339,13 +1335,13 @@ _git-rebase () { '(-i --interactive --ignore-whitespace --whitespace --committer-date-is-author-date)'{-i,--interactive}'[make a list of commits to be rebased and open in $EDITOR]' \ '--edit-todo[edit interactive instruction sheet in an editor]' \ '(-p --preserve-merges --interactive)'{-p,--preserve-merges}'[try to recreate merges instead of ignoring them]' \ - {-x,--exec}'[with -i\: append "exec <cmd>" after each line]:command' \ + {-x,--exec=}'[with -i\: append "exec <cmd>" after each line]:command:_command_names -e' \ '(1)--root[rebase all reachable commits]' \ $autosquash_opts \ '(--autostash --no-autostash)--autostash[stash uncommitted changes before rebasing and apply them afterwards]' \ '(--autostash --no-autostash)--no-autostash[do not stash uncommitted changes before rebasing and apply them afterwards]' \ '--no-ff[cherry-pick all rebased commits with --interactive, otherwise synonymous to --force-rebase]' \ - '--onto[start new branch with HEAD equal to given revision]:newbase:__git_revisions' \ + '--onto=[start new branch with HEAD equal to given revision]:newbase:__git_revisions' \ ':upstream branch:__git_revisions' \ '::working branch:__git_branch_names' } @@ -1523,6 +1519,7 @@ _git-stash () { case $state in (command) local -a commands + local -a save_arguments commands=( save:'save your local modifications to a new stash' @@ -1535,19 +1532,24 @@ _git-stash () { drop:'remove a single stashed state from the stash list' create:'create a stash without storing it in the ref namespace') + save_arguments=( + '(--keep-index)--patch[interactively select hunks from diff between HEAD and working tree to stash]' \ + '( --no-keep-index)--keep-index[all changes already added to the index are left intact]' \ + '(--keep-index )--no-keep-index[all changes already added to the index are undone]' \ + '(-q --quiet)'{-q,--quiet}'[suppress all output]' \ + '(-u --include-untracked)'{-u,--include-untracked}'[include untracked files]' \ + ) _describe -t commands command commands && ret=0 + _arguments -S $save_arguments && ret=0 # "stash" defaults to "save", but without "message". ;; (option-or-argument) curcontext=${curcontext%:*}-$line[1]: case $line[1] in (save) + _arguments -S $save_arguments && ret=0 _arguments -S \ - '(--keep-index)--patch[interactively select hunks from diff between HEAD and working tree to stash]' \ - '( --no-keep-index)--keep-index[all changes already added to the index are left intact]' \ - '(--keep-index )--no-keep-index[all changes already added to the index are undone]' \ - '(-q --quiet)'{-q,--quiet}'[suppress all output]' \ - '(-u --include-untracked)'{-u,--include-untracked}'[include untracked files]' \ + $save_arguments \ ':: :_guard "([^-]?#|)" message' && ret=0 ;; (list) @@ -3161,7 +3163,15 @@ _git-remote () { '(-m --master)'{-m,--master=}'[set HEAD of remote to point to given master branch]: :__git_branch_names' \ '--mirror[do not use separate remotes]' \ ':name:__git_remotes' \ - ':url:_urls' && ret=0 + ':repository:->repository' && ret=0 + case $state in + (repository) + _alternative \ + 'local-repositories::__git_local_repositories' \ + 'remote-repositories::__git_remote_repositories' \ + 'urls::_urls' && ret=0 + ;; + esac ;; (rename) _arguments \ @@ -3326,7 +3336,7 @@ _git-count-objects () { _git-difftool () { # TODO: Is this fine, or do we need to modify the context or similar? _git-diff \ - '--dir-diff[diff a whole tree by prepare a temporary copy]' \ + '(-d --dir-diff)'{-d,--dir-diff}'[diff a whole tree by preparing a temporary copy]' \ '(-y --no-prompt --prompt)'{-y,--no-prompt}'[do not prompt before invocation of diff tool]' \ '(-y --no-prompt)--prompt[prompt before invocation of diff tool]' \ '(-t --tool -x --extcmd)'{-t,--tool=-}'[merge resolution program to use]: :__git_difftools' \ @@ -3721,7 +3731,7 @@ _git-send-email () { '(--format-patch )--no-format-patch[interpret ambiguous arguments file-name arguments]' \ '--quiet[be less verbose]' \ '( --no-validate)--validate[perform sanity checks on patches]' \ - '(--validate )--validate[do not perform sanity checks on patches]' \ + '(--validate )--no-validate[do not perform sanity checks on patches]' \ '--force[send emails even if safety checks would prevent it]' \ '*: :_files' } @@ -5198,20 +5208,60 @@ _git_commands () { integer ret=1 - # TODO: Is this the correct way of doing it? Should we be using _alternative - # and separate functions for each set of commands instead? - _describe -t aliases alias unique_aliases && ret=0 - _describe -t main-porcelain-commands 'main porcelain command' main_porcelain_commands && ret=0 - _describe -t user-commands 'user command' user_commands && ret=0 - _describe -t third-party-commands 'third-party command' third_party_commands && ret=0 - _describe -t ancillary-manipulator-commands 'ancillary manipulator command' ancillary_manipulator_commands && ret=0 - _describe -t ancillary-interrogator-commands 'ancillary interrogator command' ancillary_interrogator_commands && ret=0 - _describe -t interaction-commands 'interaction command' interaction_commands && ret=0 - _describe -t plumbing-manipulator-commands 'plumbing manipulator command' plumbing_manipulator_commands && ret=0 - _describe -t plumbing-interrogator-commands 'plumbing interrogator command' plumbing_interrogator_commands && ret=0 - _describe -t plumbing-sync-commands 'plumbing sync command' plumbing_sync_commands && ret=0 - _describe -t plumbing-sync-helper-commands 'plumbing sync helper command' plumbing_sync_helper_commands && ret=0 - _describe -t plumbing-internal-helper-commands 'plumbing internal helper command' plumbing_internal_helper_commands && ret=0 + _tags \ + aliases \ + main-porcelain-commands \ + user-commands \ + third-party-commands \ + ancillary-manipulator-commands \ + ancillary-interrogator-commands \ + interaction-commands \ + plumbing-manipulator-commands \ + plumbing-interrogator-commands \ + plumbing-sync-commands \ + plumbing-sync-helper-commands \ + plumbing-internal-helper-commands + + while _tags; do + + _requested aliases && \ + _describe -t aliases 'alias' unique_aliases && ret=0 + + _requested main-porcelain-commands && \ + _describe -t main-porcelain-commands 'main porcelain command' main_porcelain_commands && ret=0 + + _requested user-commands && \ + _describe -t user-commands 'user command' user_commands && ret=0 + + _requested third-party-commands && \ + _describe -t third-party-commands 'third-party command' third_party_commands && ret=0 + + _requested ancillary-manipulator-commands && \ + _describe -t ancillary-manipulator-commands 'ancillary manipulator command' ancillary_manipulator_commands && ret=0 + + _requested ancillary-interrogator-commands && \ + _describe -t ancillary-interrogator-commands 'ancillary interrogator command' ancillary_interrogator_commands && ret=0 + + _requested interaction-commands && \ + _describe -t interaction-commands 'interaction command' interaction_commands && ret=0 + + _requested plumbing-manipulator-commands && \ + _describe -t plumbing-manipulator-commands 'plumbing manipulator command' plumbing_manipulator_commands && ret=0 + + _requested plumbing-interrogator-commands && \ + _describe -t plumbing-interrogator-commands 'plumbing interrogator command' plumbing_interrogator_commands && ret=0 + + _requested plumbing-sync-commands && \ + _describe -t plumbing-sync-commands 'plumbing sync command' plumbing_sync_commands && ret=0 + + _requested plumbing-sync-helper-commands && \ + _describe -t plumbing-sync-helper-commands 'plumbing sync helper command' plumbing_sync_helper_commands && ret=0 + + _requested plumbing-internal-helper-commands && \ + _describe -t plumbing-internal-helper-commands 'plumbing internal helper command' plumbing_internal_helper_commands && ret=0 + + (( ret )) || break + done return ret } @@ -5262,12 +5312,10 @@ __git_gpg_secret_keys () { (( $+functions[__git_merge_strategies] )) || __git_merge_strategies () { local expl - local -a merge_strategies - merge_strategies=(${=${${(M)${(f)"$(_call_program merge-strategies "git merge -s '' 2>&1")"}:#[Aa]vailable (custom )#strategies are: *}#[Aa]vailable (custom )#strategies are: }%.}) - __git_command_successful $pipestatus || return 1 - - _wanted merge-strategies expl 'merge strategy' compadd $* - $merge_strategies + _wanted merge-strategies expl 'merge strategy' compadd "$@" - \ + ${=${${${(M)${(f)"$(_call_program merge-strategies \ + "git merge -s '' 2>&1")"}:#[Aa]vailable (custom )#strategies are: *}#[Aa]vailable (custom )#strategies are: }%.}:-octopus ours recursive resolve subtree} } (( $+functions[__git_encodings] )) || @@ -5299,8 +5347,9 @@ __git_remotes () { local remotes expl remotes=(${(f)"$(_call_program remotes git remote 2>/dev/null)"}) + __git_command_successful $pipestatus || return 1 - _wanted remotes expl remote compadd $* - $remotes + _wanted remotes expl remote compadd "$@" -a - remotes } (( $+functions[__git_ref_specs] )) || @@ -5431,13 +5480,7 @@ __git_reflog_entries () { reflog_entries=(${${${(f)"$(_call_program reflog-entries git reflog 2>/dev/null)"}#* }%%:*}) __git_command_successful $pipestatus || return 1 - if compset -P '*@'; then - reflog_entries=(${${(M)reflog_entries:#$IPREFIX*}#$IPREFIX}) - _wanted reflog-entries expl 'reflog entry' compadd $* - $reflog_entries - else - reflog_entries=(${reflog_entries%@*}) - _wanted reflog-entries expl 'reflog entry' compadd -qS @ $* - $reflog_entries - fi + _wanted reflog-entries expl 'reflog entry' _multi_parts @ reflog_entries } (( $+functions[__git_ref_sort_keys] )) || @@ -5492,7 +5535,7 @@ __git_stashes () { stashes=(${${(f)"$(_call_program stashes git stash list 2>/dev/null)"}/: */}) __git_command_successful $pipestatus || return 1 - _wanted stashes expl stash compadd $* - $stashes + _wanted stashes expl stash compadd "$@" -a - stashes } (( $+functions[__git_svn_revisions] )) || @@ -5531,7 +5574,7 @@ __git_branch_names () { branch_names=(${${(f)"$(_call_program branchrefs git for-each-ref --format='"%(refname)"' refs/heads 2>/dev/null)"}#refs/heads/}) __git_command_successful $pipestatus || return 1 - _wanted branch-names expl branch-name compadd $* - $branch_names + _wanted branch-names expl branch-name compadd "$@" -a - branch_names } (( $+functions[__git_remote_branch_names] )) || @@ -5542,7 +5585,7 @@ __git_remote_branch_names () { branch_names=(${${(f)"$(_call_program remote-branch-refs git for-each-ref --format='"%(refname)"' refs/remotes 2>/dev/null)"}#refs/remotes/}) __git_command_successful $pipestatus || return 1 - _wanted remote-branch-names expl 'remote branch name' compadd $* - $branch_names + _wanted remote-branch-names expl 'remote branch name' compadd "$@" -a - branch_names } (( $+functions[__git_remote_branch_names_noprefix] )) || @@ -5553,7 +5596,7 @@ __git_remote_branch_names_noprefix () { branch_names=(${${${(f)"$(_call_program remote-branch-refs-noprefix git for-each-ref --format='"%(refname)"' refs/remotes 2>/dev/null)"}##*/}:#HEAD}) __git_command_successful $pipestatus || return 1 - _wanted remote-branch-names-noprefix expl 'remote branch name' compadd $* - $branch_names + _wanted remote-branch-names-noprefix expl 'remote branch name' compadd "$@" -a - branch_names } (( $+functions[__git_commits] )) || @@ -5580,14 +5623,57 @@ __git_heads () { for f in HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD; do [[ -f $gitdir/$f ]] && heads+=$f done + [[ -f $gitdir/refs/stash ]] && heads+=stash fi - _wanted heads expl head compadd $* - $heads + _wanted heads expl head compadd "$@" -a - heads } (( $+functions[__git_commit_objects] )) || __git_commit_objects () { - _guard '[[:xdigit:]](#c,40)' 'commit object name' + local gitdir expl start + declare -a commits + + # Note: the after-the-colon part must be unique across the entire array; + # see workers/34768 + : ${(A)commits::=${(f)"$(_call_program commits git --no-pager log -20 --format='%h:\\\[%h\\\]\ %s')"}} + __git_command_successful $pipestatus || return 1 + + _describe -V -t commits 'commit object name' commits || _guard '[[:xdigit:]](#c,40)' 'commit object name' +} + +(( $+functions[__git_recent_commits] )) || +__git_recent_commits () { + local gitdir expl start + declare -a descr tags heads commits + local i j k + + # Careful: most %d will expand to the empty string. Quote properly! + : "${(A)commits::=${(@f)"$(_call_program commits git --no-pager log -20 --format='%h%n%d%n%s')"}}" + __git_command_successful $pipestatus || return 1 + + for i j k in "$commits[@]" ; do + # Note: the after-the-colon part must be unique across the entire array; + # see workers/34768 + descr+=("$i:[$i] $k") + j=${${j# \(}%\)} # strip leading ' (' and trailing ')' + for j in ${(s:, :)j}; do + if [[ $j == 'tag: '* ]] ; then + tags+=( ${j#tag: } ) + else + heads+=( $j ) + fi + done + done + + ret=1 + # Resetting expl to avoid it 'leaking' from one line to the next. + expl=() + _wanted commit-tags expl 'commit tag' compadd "$@" -a - tags && ret=0 + expl=() + _wanted heads expl 'head' compadd "$@" -a - heads && ret=0 + expl=() + _describe -2Vx -t commits 'commit object name' descr && ret=0 } (( $+functions[__git_blob_objects] )) || @@ -5678,7 +5764,7 @@ __git_submodules () { submodules=(${${${(f)"$(_call_program submodules git submodule 2>/dev/null)"}#?* }%% *}) __git_command_successful $pipestatus || return 1 - _wanted submodules expl submodule compadd $* - $submodules + _wanted submodules expl submodule compadd "$@" -a - submodules } # Tag Argument Types @@ -5691,7 +5777,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 $* - $tags + _wanted tags expl tag compadd "$@" -a - tags } (( $+functions[__git_commit_tags] )) || @@ -5714,7 +5800,7 @@ __git_tags_of_type () { tags=(${${(M)${(f)"$(_call_program $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 $* - $tags + _wanted $type-tags expl "$type tag" compadd "$@" -a - tags } # Reference Argument Types @@ -5737,7 +5823,7 @@ __git_references () { _git_refs_cache_pwd=$PWD fi - _wanted references expl 'references' compadd - $_git_refs_cache + _wanted references expl 'reference' compadd -a - _git_refs_cache } (( $+functions[__git_local_references] )) || @@ -5750,7 +5836,7 @@ __git_local_references () { _git_local_refs_cache_pwd=$PWD fi - _wanted references expl 'references' compadd - $_git_local_refs_cache + _wanted references expl 'reference' compadd -a - _git_local_refs_cache } (( $+functions[__git_remote_references] )) || @@ -5766,7 +5852,7 @@ __git_notes_refs () { notes_refs=(${${(f)"$(_call_program notes-refs git for-each-ref --format='"%(refname)"' refs/notes 2>/dev/null)"}#$type refs/notes/}) __git_command_successful $pipestatus || return 1 - _wanted notes-refs expl 'notes ref' compadd $* - $notes_refs + _wanted notes-refs expl 'notes ref' compadd "$@" -a - notes_refs } # File Argument Types @@ -6406,7 +6492,6 @@ __git_config_values () { # Git Config Sections and Types (( $+functions[__git_browsers] )) || __git_browsers () { - integer ret=1 local expl declare -a userbrowsers builtinbrowsers @@ -6431,16 +6516,9 @@ __git_browsers () { cygstart xdg-open) - _tags user-browsers builtin-browsers - - while _tags; do - _requested user-browsers expl 'user-defined browser' compadd $* - $userbrowsers && ret=0 - _requested builtin-browsers expl 'builtin browser' compadd $* - $builtinbrowsers && ret=0 - - (( ret )) || break - done - - return ret + _alternative \ + 'user-browsers:user-defined browser:compadd -a - userbrowsers' \ + 'builtin-browsers:builtin browser:compadd -a - builtinbrowsers' } (( $+functions[__git_difftools] )) || @@ -6458,21 +6536,28 @@ __git_diff-or-merge-tools () { [[ $type == diff ]] && __git_config_get_regexp '^difftool\..+\.cmd$' userdifftools __git_config_get_regexp '^mergetool\..+\.cmd$' usermergetools builtintools=( + araxis + bc + bc3 + codecompare + deltawalker + diffmerge + diffuse + ecmerge + emerge + gvimdiff + gvimdiff2 + gvimdiff3 kdiff3 - tkdiff - xxdiff meld opendiff + p4merge + tkdiff + tortoisemerge vimdiff - gvimdiff vimdiff2 vimdiff3 - gvimdiff2 - emerge - ecmerge - diffuse - araxis - p4merge) + xxdiff) builtindifftools=($builtintools kompare) builtinmergetools=($builtintools tortoisemerge) @@ -6483,10 +6568,10 @@ __git_diff-or-merge-tools () { esac while _tags; do - _requested user-difftools expl 'user-defined difftool' compadd $* - $userdifftools && ret=0 - _requested user-mergetools expl 'user-defined mergetool' compadd $* - $usermergetools && ret=0 - _requested builtin-difftools expl 'builtin difftool' compadd $* - $builtindifftools && ret=0 - _requested builtin-mergetools expl 'builtin mergetool' compadd $* - $builtinmergetools && ret=0 + _requested user-difftools expl 'user-defined difftool' compadd "$@" -a - userdifftools && ret=0 + _requested user-mergetools expl 'user-defined mergetool' compadd "$@" -a - usermergetools && ret=0 + _requested builtin-difftools expl 'builtin difftool' compadd "$@" -a - builtindifftools && ret=0 + _requested builtin-mergetools expl 'builtin mergetool' compadd "$@" -a - builtinmergetools && ret=0 (( ret )) || break done @@ -6577,20 +6662,18 @@ __git_sendemail_suppresscc_values () { (( $+functions[__git_colors] )) || __git_colors () { - declare -a colors + declare -a expl - colors=(black red green yellow blue magenta cyan white) - - _describe -t colors color colors $* + _wanted colors expl color compadd "$@" - \ + black red green yellow blue magenta cyan white } (( $+functions[__git_color_attributes] )) || __git_color_attributes () { - declare -a attributes - - attributes=(bold dim ul blink reverse) + declare -a expl - _describe -t attributes attribute attributes $* + _wanted attributes expl attribute compadd "$@" - \ + bold dim ul blink reverse } # Now, for the main drive... @@ -6657,12 +6740,12 @@ _git() { (option-or-argument) curcontext=${curcontext%:*:*}:git-$words[1]: - if (( $+functions[_git-$words[1]] )); then - _call_function ret _git-$words[1] - elif zstyle -T :completion:$curcontext: use-fallback; then - _files && ret=0 - else - _message 'unknown sub-command' + if ! _call_function ret _git-$words[1]; then + if zstyle -T :completion:$curcontext: use-fallback; then + _default && ret=0 + else + _message "unknown sub-command: $words[1]" + fi fi ;; esac diff --git a/Completion/Unix/Command/_global b/Completion/Unix/Command/_global index bb6f7a0fa..c4714cb05 100644 --- a/Completion/Unix/Command/_global +++ b/Completion/Unix/Command/_global @@ -11,14 +11,30 @@ _arguments \ "$cmds"{-P,--path}'[print paths matching pattern]:pattern:' \ "$cmds"{-u,--update}'[locate tag files and update incrementally]' \ '(-a --absolute)'{-a,--absolute}'[print absolute path names]' \ + '(--color)--color=-[color matches]::color:(always auto never)' \ + '(-d --definition)'{-d,--definition}'[print locations of definitions]' \ '(-e --regexp :)'{-e,--regexp}'[specify pattern]:pattern:_global_tags' \ + '(--encode-path)--encode-path=-[encode path charcters in hexadecimal representation]:format' \ + '(-F --first-match)'{-f,--first-match}'[stop searching if tag is found in current tag file]' \ + '(--from-here)--from-here=-[decide tag type by context]:line_path:' \ '(-G --basic-regexp :)'{-G,--basic-regexp}'[specify basic regexp to use]:word:_global_tags' \ + '(--gtagsconf)--gtagsconf=-[set environment variable GTAGSCONF]:file:_files' \ + '(--gtagslabel)--gtagslabel=-[set environment variable GTAGSLABEL]:file:_files' \ '(-i --ignore-case)'{-i,--ignore-case}'[ignore case in patterns]' \ + '(-L --file-list)'{-L,--file-list}'[obtain files from file in addition to the arguments]:file:_files' \ '(-l --local)'{-l,--local}'[print just objects which exist under the current directory]' \ + '(--literal)--literal[use leteral search instead of regexp search]' \ + '(-M --match-case)'{-m,--match-case}'[enable case sensitive search]' \ + '(--match-part)--match-part=-[speficy how path name completion should match]::part:(first last all)' \ '(-n --nofilter)'{-n,--nofilter}'[suppress sort filter and path conversion filter]' \ + '(-O --only-other)'{-O,--only-other}'[search only text files]' \ '(-o --other)'{-o,--other}'[search in other files, not just source files (with -g)]' \ + '(--path-style)--path-style=-[specify path style]::style:(relative absolute shorter abslib through)' \ + '(--print0)--print0[print each record followed by a null character]' \ '(-q --quiet)'{-q,--quiet}'[quiet mode]' \ '(-r --reference --rootdir)'{-r,--reference,--rootdir}'[find object references instead of definitions]' \ + '(--result)--result=-[specify result format]::format:(path ctags ctags-x grep cscope)' \ + '(- :)--single-update=-[updata tag for specified file]:file:_files' \ '(-s --symbol)'{-s,--symbol}'[find symbols instead of function names]:pattern' \ '(-t --tags)'{-t,--tags}'[output in standard ctags format]' \ '(-T --through -s -r -l)'{-T,--through}'[search through all tag files in GTAGSLIBPATH]' \ diff --git a/Completion/Unix/Command/_gpg b/Completion/Unix/Command/_gpg index 6f2fd4834..fe236d5bf 100644 --- a/Completion/Unix/Command/_gpg +++ b/Completion/Unix/Command/_gpg @@ -1,23 +1,30 @@ -#compdef gpg gpgv gpg-zip +#compdef gpg gpgv gpg-zip gpg2=gpg local curcontext="$curcontext" state line expl ret=1 -local -a gpgbasic gpgextra gpgv gpgzip +local -a args allopts dups typeset -A opt_args -gpgv=('(-q --quiet)*'{-v,--verbose}'[increase amount of output]' - '(-q --quiet -v --verbose)'{-q,--quiet}'[reduce amount of output]' - '--keyring=[add specified file to list of keyrings]:file:_files' - '--'{status,logger}'-fd:file descriptor:_file_descriptors' - '--ignore-time-conflict' - '--homedir:directory:_directories') - -gpgzip=('--gpg[command to use instead of gpg]:command:_command' - '--gpg-args[gpg arguments]:gpg arguments:' - '--tar[command to use instead of tar]:command:_command' - '--tar-args[tar arguments]:tar arguments:' - '--list-archive[list archive contents]') +if [[ $service = gpg-zip ]]; then + args=( + '--gpg[command to use instead of gpg]:command:_command' + '--gpg-args[gpg arguments]:gpg arguments:' + '--tar[command to use instead of tar]:command:_command' + '--tar-args[tar arguments]:tar arguments:' + '--list-archive[list archive contents]' + ) +else + allopts=( $(_call_program options $words[1] --dump-options) ) + args=( + '(-q --quiet)*'{-v,--verbose}'[increase amount of output]' + '(-q --quiet -v --verbose)'{-q,--quiet}'[reduce amount of output]' + '--keyring=[add specified file to list of keyrings]:file:_files' + '--'{status,logger}'-fd:file descriptor:_file_descriptors' + '--homedir:directory:_directories' + ) +fi -gpgbasic=('(-e --encrypt)'{-e,--encrypt}'[encrypt data. this option may be combined with --sign]' +[[ $service = gpgv ]] || args+=( + '(-e --encrypt)'{-e,--encrypt}'[encrypt data. this option may be combined with --sign]' {-d,--decrypt}'[decrypt file or stdin]' '(-c --symmetric)'{-c,--symmetric}'[encrypt with symmetric cypher only]' '(-s --sign)'{-s,--sign}'[make a signature]' @@ -25,9 +32,11 @@ gpgbasic=('(-e --encrypt)'{-e,--encrypt}'[encrypt data. this option may be combi '(-u --local-user)'{-u+,--local-user}'[use name as the user ID to sign]:user attachment:_users' '(-o --output)'{-o+,--output}'[write output to file]:output file:_files' '(-h --help)'{-h,--help}'[display usage information]' - '--version[print info on program version and supported algorithms]') + '--version[print info on program version and supported algorithms]' +) -gpgextra=('--decrypt-files[decrypt multiple files]' +[[ $service = gpg ]] && args+=( + '--decrypt-files[decrypt multiple files]' '(-b --detach-sign)'{-b,--detach-sign}'[make a detached signature]' '--clearsign[make a clear text signature]' '--store[store only]' @@ -46,16 +55,14 @@ gpgextra=('--decrypt-files[decrypt multiple files]' '--edit-key[a menu for edit yours keys]:key attachment:->public-keys' '--sign-key[sign a key]:key attachment:->public-keys' '--lsign-key[sign a key but mark as non-exportable]:key attachment:->public-keys' - '--nrsign-key[sign a key non-revocably]' - '--delete-key[remove key from public keyring]:key attachment:->public-keys' - '--delete-secret-key[remove key from public & private keyring]:key attachment:->secret-keys' - '--delete-secret-and-public-key:key attachment:->secret-keys' + '--delete-keys[remove key from public keyring]:key attachment:->public-keys' + '--delete-secret-keys[remove key from public & private keyring]:key attachment:->secret-keys' + '--delete-secret-and-public-keys:key attachment:->secret-keys' '--gen-revoke[generate a revocation certificate]' '--desig-revoke[generate a designated revocation certificate]' '--export[export all key from all keyrings]' '--send-keys[send keys to a keyserver]:key attachment:->public-keyids' - '--export-all[export all key and not OpenPGP compatible keys]' - '--export-secret-keys:key attachment:->secret-keys' + '--export-secret-keys:key attahment:->secret-keys' '--export-secret-subkeys:key attachment:->secret-keys' '--import[import a gpg key from a file]:_files attachment:_files' '--fast-import[import a file without build trustdb]:_files attachment:_files' @@ -81,7 +88,7 @@ gpgextra=('--decrypt-files[decrypt multiple files]' '--no-default-recipient[reset default recipient]' '*--encrypt-to[specify recipient]:key:->public-keys' '(--encrypt-to)--no-encrypt-to[disable the use of all --encrypt-to keys]' - '(-z --compress)'{-z,--compress}'[specify compression level]:compression level:((0\:no\ compression 1\:minimum 2 3 4 5 6\:default 7 8 9\:maximum))' + '-z[specify compression level]:compression level:((0\:no\ compression 1\:minimum 2 3 4 5 6\:default 7 8 9\:maximum))' '(-t --textmode)'{-t,--textmode}'[use canonical text mode]' '(-n --dry-run)'{-n,--dry-run}"[don't make any changes]" '(-i --interactive --batch)'{-i,--interactive}'[prompt before overwriting files]' @@ -97,7 +104,7 @@ gpgextra=('--decrypt-files[decrypt multiple files]' '--keyserver-options[specify keyserver options]:options' '--import-options[specify options for importing keys]:options' '--export-options[specify options for exporting keys]:options' - '--show-photos' '--no-show-photos' '--photo-viewer:command:_command_names -e' + '--photo-viewer:command:_command_names -e' '--exec-path:path:_dir_list' '--show-keyring[display keyring name when listing keys]' '--secret-keyring[add specified file to list of secret keyrings]:file:_files' @@ -113,70 +120,45 @@ gpgextra=('--decrypt-files[decrypt multiple files]' '(--no-show-notation)--show-notation[show key signature notations]' "(--show-notation)--no-show-notation[don't show key signature notations]" '--set-policy-url:policy URL' - '(--no-show-policy-url)--show-policy-url' - '(--show-policy-url)--no-show-policy-url' '--set-filename[specify file which is stored in messages]:file:_files' - '(--for-your-eyes-only)--for-your-eyes-only' - '(--for-your-eyes-only)--no-for-your-eyes-only' '--completes-needed:number' '--marginals-needed:number' '--max-cert-depth:number' '--'{{,disable-,s2k-}cipher,{,s2k-,cert-}digest,disable-pubkey}'-algo:cipher:->ciphers' - '--s2k-mode:value' '--simple-sk-checksum' + '--s2k-mode:value' '--compress-algo:compression algorithm:((0\:disable\ compression 1\:zlib 2\:rfc1950))' - '--no-sig-cache' '--no-sig-create-check' '--'{,no-}'auto-check-trustdb' '--throw-keyid' - '--not-dash-escaped' '--'{,no-}'escape-from-lines' '--'{,no-}'use-agent' - '--rfc1991' '--'{,no-}'pgp2' '--'{,no}'pgp6' '--'{,no}'pgp7' '--openpgp' - '--'{,no-}'force-v3-sigs' '--'{,no}'force-v4-certs' '--force-mdc' '--disable-mdc' - '--'{,no-}'allow-non-selfsigned-uid' '--allow-freeform-uid' - '--ignore-valid-from' - '--ignore-crc-error' '--ignore-mdc-error' '--lock-once' '--lock-multiple' '--lock-never' - '--no-random-seed-file' '--no-verbose' '--no-greeting' '--no-secmem-warning' - '--no-permission-warning' '--no-mdc-warning' '--no-armor' '--no-default-keyring' - '--skip-verify' '--with-colons' '--with-key-data' '--with-fingerprint' - '--fast-list-mode' '--fixed-list-mode' '--list-only' '--no-literal' '--set-filesize' - '--emulate-md-encode-bug' '--show-session-key' '--override-session-key:string' - '--'{,no-}'ask-sig-expire' '--'{,no}'ask-cert-expire' '--'{,no}'expert' - '--merge-only' '--allow-secret-key-import' '--try-all-secrets' - '--enable-special-filenames' '--no-expensive-trust-checks' '--group:name=value' - '--preserve-permissions' '--personal-'{cipher,digest,compress}'-preferences:string' + '--personal-'{cipher,digest,compress}'-preferences:string' '--card-edit[present smartcard menu]' '--card-status[show smartcard content]' '--change-pin[present menu to change smartcard pin]' '--list-config[display internal configuration parameters]' '--hidden-recipient[hidden recipient]:recipient:->public-keys' '--dump-options[show all options]' '--default-preference-list:string' - '--fetch-keys:URIs:' '--gpgconf-list' '--gpgconf-test' + '--fetch-keys:URIs' '--hidden-encrypt-to:recipient:->public-keys' - '--compress-level:integer:' - '--bzip2-compress-level:integer:' '--bzip2-decompress-lowmem' - '--default-sig-expire' '--default-cert-expire' '--no-ask-cert-expire' - '--default-cert-level:integer:' - '--min-cert-level' '--ask-cert-level' '--no-ask-cert-level' + '--compress-level:integer' + '--bzip2-compress-level:integer' + '--default-cert-level:integer' '--max-output[maximum output generated when processing file]:bytes:' '--gpg-agent-info[override GPG_AGENT_INFO]:' '--primary-keyring:file:_files' - '--'{,no-}'verify-options:parameters:_multi_parts -q -S, "," + '--verify-options:parameters:_multi_parts -q -S, "," "(show-photos show-policy-urls show-notations show-std-notations show-user-notations show-keyserver-urls show-uid-validity show-unusable-uids show-primary-uid-only pka-lookups pka-trust-increase)"' - '--debug:flags:' '--debug-all' '--status-file:file:' - '--attribute-file:file:' '--load-extension:file:_files' - '--gnupg' '--rfc2440' '--rfc4880' '--pgp8' - '--s2k-count:integer:' '--'{,no-}'throw-keyids' + '--debug:flags:' '--status-file:file:_files' + '--attribute-file:file:_files' '--load-extension:file:_files' + '--s2k-count:integer' '--sig-notation:name=value:' '--cert-notation:name=value:' '--passphrase-file:file:_files' '--passphrase-repeat:integer:' '--command-file:file:_files' '--trustdb-name:file:_files' - '--'{,no-}'require-secmem' '--trust-model:trust model:((pgp classic direct always auto))' '--sig-policy-url:string:' '--cert-policy-url:string:' '--sig-keyserver-url:string:' '--comment[comment]:comment:' '--no-comments[disable comments]' '--logger-file[write log to file]:file:_files' - '--'{,no-}'use-embedded-filename' '--rebuild-keydb-caches[create signature caches in keyring]' '--default-keyserver-url:name:' '--display-charset[set native charset]:charset:((iso-8859-1 iso-8859-2 iso-8859-15 koi8-r utf-8))' '--ungroup[remove group]:group name:' '--no-groups[remove all entries from --group list]' - '--'{,no}'mangle-dos-filenames' '--enable-progress-filter[enable progress status output]' '--multifile[process multiple files]' '--keyid-format[key id format]:key format:((short 0xshort long 0xlong))' @@ -185,25 +167,13 @@ gpgextra=('--decrypt-files[decrypt multiple files]' '--reader-port[card reader port]:port:' '--ctapi-driver[file to use to access smartcard reader]:file:_files' '--pcsc-driver[file to use to access smartcard reader]:file:_files' - '--disable-ccid' '--debug-ccid-driver' - '--'{enable,disable}'-dsa2' - '--'{,no-}'allow-multiple-messages' '--'{,no-}'require-cross-certification' - '--auto-key-locate:parameters:' '--no-auto-key-locate' - '--dump-options[show all options]') - -case "$service" in - gpg) - _arguments -C -s -S -A "-*" $gpgbasic $gpgextra $gpgv '*:args:->args' && ret=0 - ;; + '--auto-key-locate:parameters' + '--dump-options[show all options]' +) - gpgv) - _arguments -C -s -S -A "-*" $gpgv '*:args:->args' && ret=0 - ;; - - gpg-zip) - _arguments -C -s -S -A "-*" $gpgbasic $gpgzip '*:args:->args' && ret=0 - ;; -esac +extra=( ${${${args#\([^\)]#\)}#\*}%%[:=\[]*} ) +extra=( ${allopts:|extra} ) +_arguments -C -s -S -A "-*" $args $extra '*:args:->args' && ret=0 if [[ $state = args ]]; then if (( ${+opt_args[--export]} || ${+opt_args[--list-keys]} || ${+opt_args[--list-public-keys]} )); then diff --git a/Completion/Unix/Command/_grep b/Completion/Unix/Command/_grep index 5068f6e48..d987c2b1e 100644 --- a/Completion/Unix/Command/_grep +++ b/Completion/Unix/Command/_grep @@ -1,4 +1,4 @@ -#compdef grep egrep fgrep -value-,GREP_OPTIONS,-default- +#compdef grep egrep fgrep bsdgrep zgrep, zegrep, zfgrep -value-,GREP_OPTIONS,-default- # Ulrik Haugen 2001 local arguments matchers command diff --git a/Completion/Unix/Command/_hg b/Completion/Unix/Command/_hg index c18500bcb..e7c21b9d1 100644 --- a/Completion/Unix/Command/_hg +++ b/Completion/Unix/Command/_hg @@ -162,15 +162,24 @@ _hg_revrange() { _hg_tags "$@" } -_hg_tags() { - typeset -a tags - local tag rev +_hg_tags_internal() { + local expl + typeset -a hgtags + hgtags=( ${(f)"$(_hg_cmd tags -q 2>/dev/null)"} ) + _wanted tags expl 'tags' compadd -a - hgtags +} - _hg_cmd tags 2> /dev/null | while read tag - do - tags+=(${tag/ # [0-9]#:*}) - done - (( $#tags )) && _describe -t tags 'tags' tags +_hg_bookmarks_internal() { + local expl + typeset -a hgbookmarks + hgbookmarks=( ${(f)"$(_hg_cmd bookmarks -q 2>/dev/null)"} ) + _wanted bookmarks expl 'bookmarks' compadd -a - hgbookmarks +} + +_hg_tags() { + _alternative \ + 'bookmarks:bookmark:_hg_bookmarks_internal' \ + 'tags:tag:_hg_tags_internal' } # likely merge candidates diff --git a/Completion/Unix/Command/_iconv b/Completion/Unix/Command/_iconv index 82c2d320a..d040be756 100644 --- a/Completion/Unix/Command/_iconv +++ b/Completion/Unix/Command/_iconv @@ -1,8 +1,8 @@ #compdef iconv -local expl curcontext="$curcontext" state line ret=1 +local expl curcontext="$curcontext" state line variant ret=1 -if _pick_variant libiconv='GNU*libiconv' glibc='(GNU*libc|EGLIBC)' unix --version; then +if _pick_variant -r variant libiconv='GNU*libiconv' glibc='(GNU*libc|EGLIBC|Gentoo)' unix --version; then local -a args local exargs="-l --list -? --help --usage --version -V" @@ -13,22 +13,22 @@ if _pick_variant libiconv='GNU*libiconv' glibc='(GNU*libc|EGLIBC)' unix --versio "($exargs)-c[omit invalid characters from output]" "(-s --silent --verbose $exargs)"{-s,--silent}'[suppress warnings]' '(-)'{-\?,--help}'[display help information]' - '(-)--usage[display a short usage message]' '(-)'{-V,--version}'[print program version]' '1:input file:_files' ) - case $_cmd_variant[$service] in + case $variant in (libiconv) args=( ${(R)args:#(|\*)(|\(*\))-[V\?]*} ) # remove -V and -? args+=( - '--byte-subst=[format for unconvertible bytes]:format string:' - '--widechar-subst=[format for unconvertible wide chars]:format string:' - '--unicode-subst=[format for unconvertible Unicode chars]:format string:' + '--byte-subst=[format for unconvertible bytes]:format string' + '--widechar-subst=[format for unconvertible wide chars]:format string' + '--unicode-subst=[format for unconvertible Unicode chars]:format string' ) ;; (glibc) args+=( + '(-)--usage[display a short usage message]' "(-o --output $exargs)"{-o+,--output=}'[specify output file]:output file:_files' "(-s --silent $exargs)--verbose[print progress information]" ) @@ -44,7 +44,7 @@ if _pick_variant libiconv='GNU*libiconv' glibc='(GNU*libc|EGLIBC)' unix --versio else _wanted codesets expl 'code set' compadd "$@" \ -M 'm:{a-zA-Z}={A-Za-z} r:|-=* r:|=*' \ - ${$(_call_program codesets iconv --list)%//} && ret=0 + ${$(_call_program codesets $words[1] --list)%//} && ret=0 fi fi @@ -55,12 +55,17 @@ else local -U codeset _arguments -C \ - '-f[specify code set of input file]:code set:->codeset' \ - '-t[specify code set for output]:code set:->codeset' \ + '(-l)-f[specify code set of input file]:code set:->codeset' \ + '(-l)-t[specify code set for output]:code set:->codeset' \ + '(-l)-c[omit invalid characters from output]' \ + '(-l)-s[suppress warnings]' \ + '(- 1)-l[list all character code sets]' \ '1:file:_files' && return 0 if [[ $state = codeset ]]; then - if [[ -f /usr/lib/iconv/iconv_data ]]; then # IRIX & Solaris + if [[ $OSTYPE = freebsd* ]]; then + codeset=( $(_call_program codesets $words[1] -l) ) + elif [[ -f /usr/lib/iconv/iconv_data ]]; then # IRIX & Solaris codeset=( ${${(f)"$(</usr/lib/iconv/iconv_data)"}%%[[:blank:]]*} ) codeset+=( /usr/lib/iconv/*%*.so(Ne.'reply=( ${${REPLY:t}%%%*} ${${REPLY:r}#*%} )'.) ) elif [[ -d $LOCPATH/iconv ]]; then # OSF @@ -70,7 +75,7 @@ else return 1 fi - _wanted codesets expl 'code set' compadd "$@" -a codeset + _wanted codesets expl 'code set' compadd -a codeset fi fi diff --git a/Completion/Unix/Command/_id b/Completion/Unix/Command/_id index 36cdf4c19..74fe6d9e1 100644 --- a/Completion/Unix/Command/_id +++ b/Completion/Unix/Command/_id @@ -1,13 +1,49 @@ -#compdef id +#compdef id gid -_arguments \ - '-a[no-op]' \ - '(-Z --context)'{-Z,--context}'[print only context]' \ - '(-g --group)'{-g,--group}'[print only EGID]' \ - '(-G --groups)'{-G,--groups}'[print all GIDs]' \ - '(-n --name)'{-n,--name}'[print name instead of number]' \ - '(-r --real)'{-r,--real}'[print real ID instead of effective]' \ - '(-u --user)'{-u,--user}'[print only EUID]' \ - '--help[display help]' \ - '--version[display version]' \ - ':user:_users' +local args choices + +if _pick_variant gnu=GNU $OSTYPE --version; then + choices='--help --version -Z --context -g --group -G --groups -u --user' + _arguments \ + "($choices)"{-Z,--context}'[print only security context]' \ + "($choices)"{-g,--group}'[print only EGID]' \ + "($choices -r --real)"{-G,--groups}'[print all GIDs]' \ + '(-n --name --help --version)'{-n,--name}'[show name instead of number]' \ + '(-r --real -g --groups --help --version)'{-r,--real}'[show real ID instead of effective]' \ + "($choices)"{-u,--user}'[print only EUID]' \ + '(-z --zero --help --version)'{-z,--zero}'[delimit entries with NUL characters]' \ + '(- :)--help[display help information]' \ + '(- :)--version[display version]' \ + ':user:_users' +else + choices="-A -a -c -G -g -M -p -P -u" + args=( + "($choices)-g[print only EGID]" + "($choices -r)-G[print all GIDs]" + "($choices)-u[print only EUID]" + '(-A -c -M -P)-n[show name instead of number]' + '(-A -c -M -P)-r[show real ID instead of effective]' + ) + case $OSTYPE in + solaris*) + args+=( + '(-g -G -u -n -r)-a[show user name, user ID and all the groups]' + '(-g -G -u -n -r)-p[show project membership]' + ) + ;; + darwin*|dragonfly*|freebsd*) + args+=( '(-)-P[print id in the form of a password file entry]' ) + ;| + darwin*|freebsd*) + args+=( + '(-)-A[print process audit user ID]' + '(-)-M[print MAC label of the current process]' + ) + ;| + freebsd*) args+=( '(-)-c[print current login class]' ) ;| + darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) + args+=( '(-)-p[human readable output]' ) + ;; + esac + _arguments -s $args ':user:_users' +fi diff --git a/Completion/Unix/Command/_ip b/Completion/Unix/Command/_ip index f880f2683..bfa7d995b 100644 --- a/Completion/Unix/Command/_ip +++ b/Completion/Unix/Command/_ip @@ -8,8 +8,11 @@ # # Values encoding simple types # -local -a subcmd_dev -subcmd_dev=(/$'[[:alpha:]]##[[:digit:]]##(\.[[:digit:]]##)#\0'/ ':interfaces:network interface:_net_interfaces') +local -a subcmd_dev net_intf_disp net_intf_list +# subcmd_dev=(/$'[[:alnum:][:punct:][:cntrl:][:digit:]]##\0'/ ':interfaces:network interface:_net_interfaces') +_find_net_interfaces +subcmd_dev=(/"(${(j.|.)net_intf_list})"$'\0'/ + ':interfaces:network interface:_net_interfaces') local -a subcmd_onoff subcmd_onoff=(/$'(on|off)\0'/ ':onoff:state (on or off):(on off)') @@ -38,6 +41,7 @@ subcmd_ipaddrs=( /$'(<->(.<->(.<->(.<->|)|)|)|[:[:xdigit]]#:[:[:xdigit:]]#)(|/<->)\0'/ ":ipaddress:IP address (v4 or v6) currently set:( $(ip addr show | sed -n 's/^ *inet6* \([0-9a-f\.:/]*\) .*$/\1/p') )" ) +local -a subcmd_prefix_label subcmd_prefix_label=( /$'(<->(.<->(.<->(.<->|)|)|)|[:[:xdigit]]#:[:[:xdigit:]]#)(|/<->)\0'/ ":ipaddresslabel:IP addrlabel prefix currently set:( $(ip -6 addrlabel list 2>/dev/null | sed -n 's/^prefix \([0-9a-f\.:/]*\) .*$/\1/p') )" @@ -98,7 +102,7 @@ _regex_words nexthop 'nexthop route keyword' \ 'weight:specify relative quality of route:$subcmd_number' subcmd_nexthop=("$reply[@]" "#") -local -a subcmd_rtproto +local -a subcmd_rtprotocol _regex_words rtprotocol 'route protocol' \ 'redirect:installed from ICMP redirect' \ 'kernel:installed automatically by kernel' \ diff --git a/Completion/Unix/Command/_join b/Completion/Unix/Command/_join index 956d9d3b8..4915a0600 100644 --- a/Completion/Unix/Command/_join +++ b/Completion/Unix/Command/_join @@ -1,23 +1,29 @@ -#compdef join +#compdef join gjoin -# completions for GNU join version 5.97 - -local arguments - -arguments=( - '-a+[print unpairable lines coming from file FILENUM, where FILENUM is 1 or 2, corresponding to FILE1 or FILE2]:file number:(1 2)' - '-e+[replace missing input fields with EMPTY]:replacement string:' - '(-i --ignore-case)'{-i,--ignore-case}'[ignore differences in case when comparing fields]' - "-j+[equivalent to '-1 FIELD -2 FIELD']:field number:" - '-o+[obey FORMAT while constructing output line]:format string:' - '-t+[use CHAR as input and output field separator]:separator:' - '-v+[like -a FILENUM, but suppress joined output lines]:file number:(1 2)' - '-1+[join on this FIELD of file 1]:field number:' - '-2+[join on this FIELD of file 2]:field number:' - --help'[display help and exit]' - --version'[output version information and exit]' - '1:file 1:_files' - '2:file 2:_files' +local args variant +args=( + '*-a+[print unpairable lines from specified file]:file number:(1 2)' + '-e+[replace missing input fields with specified string]:replacement string' + "(-1 -2)-j+[join on specified field for both files]:field number" + '-o+[use specified output format]:format string' + '-t+[use specified character as field separator]:separator' + '*-v+[like -a, but suppress joined output lines]:file number:(1 2)' + '(-j -1 -j1)'{-j1,-1+}'[join on specified field of first file]:field number' + '(-j -2 -j2)'{-j2,-2+}'[join on specified field of second file]:field number' + '1:file:_files' '2:file:_files' +) +_pick_variant -r variant gnu=GNU $OSTYPE --version +case $variant in + gnu) + args+=( + '(-i --ignore-case)'{-i,--ignore-case}'[ignore differences in case when comparing fields]' + '(-)--help[display help information]' + '(-)--version[output version information]' + '(--check-order --nocheck-order)'{--check-order,--nocheck-order} + '--header[treat first line in each file as field headers]' + '(-z --zero-terminated)'{-z,--zero-terminated}'[end lines with 0 byte, not newline]' ) + ;; +esac -_arguments -s $arguments +_arguments -s $args diff --git a/Completion/Unix/Command/_last b/Completion/Unix/Command/_last index 43a08a709..706d82f26 100644 --- a/Completion/Unix/Command/_last +++ b/Completion/Unix/Command/_last @@ -1,17 +1,53 @@ #compdef last lastb -_arguments -s \ - '-a[display hostname in last column]' \ - '-n[number]:number' \ - '-[number]:number' \ - '-f[filename]:filename:_files' \ - '-R[suppress display of hostname field]' \ - '-d[translate IP to hostname]' \ - '-i[display IP]' \ - '-o[read old-format wtmp]' \ - '-x[display shutdown/runlevel entries]' \ - '-h[hostname]:host:_hosts' \ - '-s[report duration in seconds]' \ - '-t[tty]:tty' \ - '-w[widen duration field]' \ - '*:user:_users' +local pattern arg args ttys +ttys=( /dev/tty*(N) /dev/pts/*(N) reboot ) +ttys=( ${ttys#/dev/} ) + +for pattern arg in \ + '(solaris*|linux-gnu)' '-a[display hostname in last column]' \ + '((free|net|open)bsd*|darwin*|dragonfly*|linux-gnu)' '-h[limit sessions by hostname]:host:_hosts' \ + '((free|open)bsd*|linux-gnu)' '-s[report duration in seconds]' \ + '(freebsd*|openbsd*)' '-d[limit sessions to those active at snapshot time]:time ([[CC]YY][MMDD]hhmm[.SS])' \ + '((net|free|open)bsd*|darwin*|dragonfly*)' '-t[limit sessions by tty]:tty:compadd -a ttys' \ + 'openbsd*' '-c[calculate total time]' \ + '^darwin*' '-f[specify account file]:file:_files' \ + '(solaris*|linux-gnu|freebsd*|openbsd*)' '-n[specify number of lines to show]:number' \ + '((open|net)bsd*|dragonfly*)' '-T[show more detailed time information including year and seconds]' \ + 'netbsd*' '-x[assume file is in wtmpx(5) format]' \ + 'netbsd*' '-n[show IP of remote hosts]' \ + 'freebsd*' '-w[show seconds in durarion field]' \ + 'freebsd*' '-y[show year in session start time]' +do + [[ $OSTYPE = $~pattern ]] && args+=( $arg ) +done + +case $OSTYPE in + netbsd*|dragonfly*) + args+=( + '-H[specify width for host field]:width' + '-N[specify width for login name field]:width' + '-L[specify width for tty field]:width' + ) + ;; + linux-gnu) + args+=( + '-R[suppress display of hostname field]' + '-d[translate IP to hostname]' + '-F[show full login and logout times and dates]' + '-i[show IP of remote hosts]' + '-o[read old-format wtmp]' + '-t[limit sessions to those active at snapshot time]:time (YYYYMMDDhhmmss)' + '-w[show full user and domain names]' + '-x[display shutdown/runlevel entries]' + ) + ;; +esac + +if [[ $OSTYPE = (linux-gnu|solaris*) ]]; then + args+=( '*:arg: _alternative "users:user:_users" "ttys:tty:compadd -a ttys"' ) +else + args+=( '*:user:_users' ) +fi + +_arguments -s $args diff --git a/Completion/Unix/Command/_ldd b/Completion/Unix/Command/_ldd index 0980bc043..19b8a9105 100644 --- a/Completion/Unix/Command/_ldd +++ b/Completion/Unix/Command/_ldd @@ -1,6 +1,6 @@ #compdef ldd -if _pick_variant gnu='(GNU|EGLIBC)' solaris --version; then +if _pick_variant gnu='(GNU|EGLIBC|Gentoo)' unix --version; then args=( '(- *)--version[display version information]' '(- *)--help[display help information]' @@ -10,20 +10,31 @@ if _pick_variant gnu='(GNU|EGLIBC)' solaris --version; then '(-u --unused)'{-u,--unused}'[display any unused objects]' ) else - args=( - -s - '(-r)-d[check immediate references]' - '(-d)-r[check immediate and lazy references]' - '-u[display any unused objects]' - '-U[display any unreferenced, or unused dependencies]' - '-e[set specified environment variable]:environment variable:(LD_PRELOAD LD_LIBRARY_PATH LD_RUN_PATH LD_DEBUG LD_DEBUG_OUTPUT LD_NOCONFIG LD_NOAUXFLTR)' - '-f[check for insecure executable]' - '-i[display order of execution of initialization sections]' - '-L[enable lazy loading]' - '-l[force immediate processing of any filters]' - '-s[display search path used]' - '-v[displays all dependency relationships]' - ) + case $OSTYPE in + solaris*) + args=( + -s + '(-r)-d[check immediate references]' + '(-d)-r[check immediate and lazy references]' + '-u[display any unused objects]' + '-U[display any unreferenced, or unused dependencies]' + '-e[set specified environment variable]:environment variable:(LD_PRELOAD LD_LIBRARY_PATH LD_RUN_PATH LD_DEBUG LD_DEBUG_OUTPUT LD_NOCONFIG LD_NOAUXFLTR)' + '-f[check for insecure executable]' + '-i[display order of execution of initialization sections]' + '-L[enable lazy loading]' + '-l[force immediate processing of any filters]' + '-s[display search path used]' + '-v[displays all dependency relationships]' + ) + ;; + freebsd*) + args=( + '-a[show all objects that are needed by each loaded object]' + '-v[verbose listing of the dynamic linking headers]' + '-f+[specify format]:format:((%a\:program\ name %A\:environment\ name %o\:library\ name %p\:path\ to\ library %x\:load\ address))' + ) + ;; + esac fi _arguments $args \ diff --git a/Completion/Unix/Command/_less b/Completion/Unix/Command/_less index ede54a49c..a3ba8f665 100644 --- a/Completion/Unix/Command/_less +++ b/Completion/Unix/Command/_less @@ -24,8 +24,8 @@ if compset -P '+[-0-9]#'; then g:goto\ line F:scroll\ to\ end\ and\ keep\ reading\ file G:go\ to\ end\ of\ file - %:go\ to\ position\ in\ file - p:go\ to\ position\ in\ file + %:go\ to\ position\ in\ file + p:go\ to\ position\ in\ file )' return fi @@ -101,9 +101,9 @@ if [[ -n "$state" ]]; then ;; tags) if (( $+LESSGLOBALTAGS )); then - _global_tags + _global_tags && ret=0 else - _ctags_tags + _ctags_tags && ret=0 fi ;; esac diff --git a/Completion/Unix/Command/_lha b/Completion/Unix/Command/_lha index 5a238d807..c2d5e7d8d 100644 --- a/Completion/Unix/Command/_lha +++ b/Completion/Unix/Command/_lha @@ -5,16 +5,16 @@ if (( CURRENT == 2 )); then local lhacmds lhacmds=( - '( x l v u d m c p t)a[Add \(Or replace\) to archive]' - '(a l v u d m c p t)x[EXtract from archive]' - '(a x v u d m c p t)l[List]' - '(a x l u d m c p t)v[Verbose List]' - '(a x l v d m c p t)u[Update newer files to archive]' - '(a x l v u m c p t)d[Delete from archive]' - '(a x l v u d c p t)m[Move to archive]' - '(a x l v u d m p t)c[re-Construct new archive]' - '(a x l v u d m c t)p[Print to STDOUT from archive]' - '(a x l v u d m c p )t[Test file CRC in archive]' + '( x l v u d m c p t)a[add \(or replace\) to archive]' + '(a l v u d m c p t)x[extract from archive]' + '(a x v u d m c p t)l[list]' + '(a x l u d m c p t)v[verbose List]' + '(a x l v d m c p t)u[update newer files to archive]' + '(a x l v u m c p t)d[delete from archive]' + '(a x l v u d c p t)m[move to archive]' + '(a x l v u d m p t)c[re-construct new archive]' + '(a x l v u d m c t)p[print to stdout from archive]' + '(a x l v u d m c p )t[test file CRC in archive]' ) if [ "${words[2]#-}" != "" ]; then @@ -23,22 +23,22 @@ if (( CURRENT == 2 )); then 'q[quiet]' 'n[not execute]' 'f[force\(over write at extract\)]' - 't[FILES are TEXT file]' - 'e[TEXT code convert from/to EUC]' - 'g[Generic format \(for compatibility\)]' + 't[files are text files]' + 'e[text code convert from/to EUC]' + 'g[use generic format \(for compatibility\)]' ) case ${words[2]#-} in a*|u*) lhacmds=($lhacmds - 'd[delete FILES after]' - 'z[files not compress]' + 'd[delete files after]' + "z[don't compress files]" '( 1 2)0[header level 0]' '(0 2)1[header level 1]' '(0 1 )2[header level 2]' ) ;; c*) - lhacmds=($lhacmds 'd[delete FILES after]') + lhacmds=($lhacmds 'd[delete files after]') ;; x*) lhacmds=($lhacmds 'i[ignore directory path]') @@ -46,32 +46,25 @@ if (( CURRENT == 2 )); then esac fi - _values -s '' 'lha command' \ - $lhacmds \ - && return 0 + _values -s '' 'lha command' $lhacmds elif (( CURRENT == 3 )); then - _arguments -C \ - '*:LHA file:_files -g \*.lzh' && return 0 + _wanted files expl 'lha file' _files -g '*.lzh(-.)' else case ${words[2]#-} in l*|x*|d*) if [ -f "$words[3]" ]; then - _lzh_cache_list=`$words[1] lq $words[3] | awk '{print $8}'` + _lzh_cache_list=`$words[1] lq $words[3] | awk '{print $NF}'` _lzh_cache_list=("${(@f)${_lzh_cache_list}}") _wanted files expl 'file from archive' _multi_parts / _lzh_cache_list - - return 0 else - _message -r "Archive file is not found : ${words[3]}" + _message -r "archive file is not found : ${words[3]}" return 1 fi ;; *) - _arguments -C \ - '*:file:_files' && return 0 + _files + ;; esac fi - -return 0 diff --git a/Completion/Unix/Command/_ln b/Completion/Unix/Command/_ln index 89b7177ab..c903fee02 100644 --- a/Completion/Unix/Command/_ln +++ b/Completion/Unix/Command/_ln @@ -1,12 +1,19 @@ -#compdef ln gln +#compdef ln gln zf_ln local curcontext="$curcontext" state line ret=1 local -A opt_args -local -a args +local -a args bsd args=( '-f[remove existing destination files]' - '-s[create symbolic links instead of hard links]') + '-s[create symbolic links instead of hard links]' +) +bsd=( + '-F[remove existing destination directories]' + {-h,-n}'[do not dereference destination]' + '-i[prompt before removing destination files]' + '-v[print name of each linked file]' +) local -a opts @@ -44,14 +51,16 @@ elif (( ${+builtins[ln]} )); then {-h,-n}'[do not dereference destination]' '-i[prompt before removing destination files]') elif [[ $OSTYPE == darwin* ]]; then - args+=( - '-F[remove existing destination directories]' - {-h,-n}'[do not dereference destination]' - '-i[prompt before removing destination files]' - '-v[print name of each linked file]') + args+=( $bsd ) +elif [[ $OSTYPE == freebsd* ]]; then + args+=( $bsd + '(-L)-P[create hard links directly to symbolic links]' + '(-P)-L[create hard links to symbolic link references]' + "-w[warn if source of a symbolic link doesn't currently exist]" + ) fi -_arguments -s $opts \ +_arguments -C -s $opts \ $args \ ':link target:_files' \ '*:: :->files' && ret=0 diff --git a/Completion/Unix/Command/_ls b/Completion/Unix/Command/_ls index 7680f9273..f2e149453 100644 --- a/Completion/Unix/Command/_ls +++ b/Completion/Unix/Command/_ls @@ -1,11 +1,8 @@ #compdef ls gls -# Ulrik Haugen 2001 local arguments is_gnu -_pick_variant -r is_gnu gnu=gnu unix --help - -if [[ "$OSTYPE" = (netbsd*|freebsd*|openbsd*|darwin*) && "$is_gnu" != gnu ]]; then +if ! _pick_variant gnu=gnu unix --help; then arguments=( '(-A)-a[list entries starting with .]' '(-a)-A[list all except . and ..]' @@ -14,10 +11,8 @@ if [[ "$OSTYPE" = (netbsd*|freebsd*|openbsd*|darwin*) && "$is_gnu" != gnu ]]; th '-R[list subdirectories recursively]' '(-k)-h[print sizes in human readable form]' - '(-h)-k[print sizes of 1k]' '-i[print file inode numbers]' - '(-l -g -1 -C -m -x)-l[long listing]' '(-l -1 -C -m -x)-g[long listing but without owner information]' '(-l -g -C -m -x)-1[single column output]' @@ -25,35 +20,36 @@ if [[ "$OSTYPE" = (netbsd*|freebsd*|openbsd*|darwin*) && "$is_gnu" != gnu ]]; th '(-l -g -1 -C -x)-m[comma separated]' '(-l -g -1 -C -m)-x[sort horizontally]' - '-o[display file flags]' - '-s[display size of each file in blocks]' '(-u)-c[status change time]' '(-c)-u[access time]' - '-f[unsorted, all, short list]' '-r[reverse sort order]' - '(-t)-S[sort by size]' '(-S)-t[sort by modification time]' '(-p)-F[append file type indicators]' '(-F)-p[append file type indicators for directory]' - '-f[output is not sorted]' - '-n[numeric uid, gid]' - '-T[show complete time information]' - - '(-B -b -w -q)-B[print octal escapes for control characters]' '(-B -b -w -q)-b[as -B, but use C escape codes whenever possible]' '(-B -b -w -q)-q[hide control chars]' - '(-B -b -w -q)-w[print raw characters]' '*:files:_files' ) + if [[ "$OSTYPE" = (netbsd*|dragonfly*|freebsd*|openbsd*|darwin*) ]]; then + arguments+=( + '(-h)-k[print sizes of 1k]' + '(-t)-S[sort by size]' + '-T[show complete time information]' + '-o[display file flags]' + '-f[output is not sorted]' + '(-B -b -w -q)-w[print raw characters]' + '(-B -b -w -q)-B[print octal escapes for control characters]' + ) + fi if [[ "$OSTYPE" = (freebsd*|darwin*) ]]; then arguments+=( '-G[enable colorized output]' @@ -61,6 +57,18 @@ if [[ "$OSTYPE" = (netbsd*|freebsd*|openbsd*|darwin*) && "$is_gnu" != gnu ]]; th '-P[do not follow symlinks]' ) fi + if [[ $OSTYPE = solaris* ]]; then + arguments+=( + '(-l -1 -C -m -x)-o[long listing but without group information]' + '(-l -t -s -r -a)-f[interpret each argument as a directory]' + '(-E -l)-e[long listing with full and consistent date/time]' + '(-e -l)-E[long listing with ISO format date/time]' + '-H[follow symlinks on the command line]' + '-v[long listing with verbose ACL information]' + '-V[long listing with compact ACL information]' + '-@[long listing with marker for extended attribute information]' + ) + fi else arguments=( '(--all -a -A --almost-all)'{--all,-a}'[list entries starting with .]' @@ -131,10 +139,6 @@ else '(- :)--version[display version information]' '*:files:_files' ) - # remove long options? - if [[ $is_gnu != gnu ]]; then - arguments=( ${${${arguments:#(|*\))--*}//--[^ )]#/}/\( #\)/} ) - fi fi _arguments -s $arguments diff --git a/Completion/Unix/Command/_lsof b/Completion/Unix/Command/_lsof index aca9963c2..c12b9910a 100644 --- a/Completion/Unix/Command/_lsof +++ b/Completion/Unix/Command/_lsof @@ -1,20 +1,35 @@ #compdef lsof -_arguments -s -S \ +local curcontext="$curcontext" state line fields args + +case $OSTYPE in + linux*) args=( '-X[skip reporting of info on network connections]' ) ;; + solaris*) + args=( + '-X[include deleted files]' + '-z[zone information]::zone:_zones' + ) + ;; +esac + +_arguments -C -s -S $args \ '(-)'{-\?,-h}'[list help]' \ '-a[AND selections]' \ '-b[avoid kernel blocks]' \ '-C[disable reporting of path name components]' \ - '-c[list files for command beginning with specified char]:char' \ + '+c[truncate command name to specified characters]:characters' \ + '-c[list files with specified command name beginning]:command name' \ '+d[search for open instances for contents of specified dir]:search directory:_files -/' \ - '-d[specify list of file descriptors to exclude/include]:file descriptors' \ + '-d[specify list of file descriptors to exclude/include]:file descriptors:->filedes' \ '+D[recursively search from specified dir]:search directory:_files -/' \ '-D[direct use of device cache file]:function:((\?\:report\ device\ cache\ file\ paths b\:build\ the\ device\ cache\ file i\:ignore\ the\ device\ cache\ file r\:read\ the\ device\ cache\ file u\:read\ and\ update\ the\ device\ cache\ file))' \ - '-f[inhibit listing of kernel file structure info]::info type or path' \ - '+f[enable listing of kernel file structure info]::info type' \ - '-F[select output fields]:fields' \ + '*-+e[exempt filesystem from blocking kernel calls]:file system:_directories' \ + '-f[inhibit listing of kernel file structure info]::info type or path:(c f g G n)' \ + '+f[enable listing of kernel file structure info]::info type:(c f g G n)' \ + '-F[select output fields]:fields:->fields' \ '-g[select by process group id]::process group id' \ '*-i[select internet files]:address' \ + '-K[select listing of tasks of processes]' \ '-k[specify kernel name list file]:kernel file:_files' \ '-l[inhibit conversion of UIDs to user names]' \ '-L[list no link counts]' \ @@ -24,10 +39,10 @@ _arguments -s -S \ '+M[enable reporting of portmapper registrations]' \ '-n[inhibit conversion of network numbers to hostnames]' \ '-N[select listing of NFS files]' \ - '(-s)-o[list file offset]' \ + '(-s)-o[list file offset]::digits for file offset' \ '-O[avoid overheads of bypassing potential blocking]' \ '-P[inhibit conversion of port numbers to port names]' \ - '-p[list files for specified processes]:process ID:_pids' \ + '-p[list files for specified processes]:process ID:_sequence -s , _pids' \ '-r[repeat listing endlessly]::delay (seconds)' \ '+r[repeat listing until no files listed]::delay (seconds)' \ '-R[list parent PID]' \ @@ -41,4 +56,19 @@ _arguments -s -S \ '-V[indicate unsuccessfully searched for items]' \ '(-t)+w[suppress warnings]' \ '(-t)-w[enable warnings]' \ - '*:file:_files' + '-x[cross filesystems/traverse symlinks with +d/+D]::type:((f\:filesystems s\:symlinks))' \ + '*:file:_files' && return + +case $state in + fields) + fields=( ${${${${(f)"$($words[1] -F \? 2>&1)"}[2,-1]#??}// ##/:}:#(#s)[${PREFIX:-:}]:*} ) + compset -P '*' + _describe -t fields "field" fields -S '' && return + ;; + filedes) + _sequence -s , _wanted -x file-descriptors expl "file descriptor" compadd - \ + cwd err jld ltz mem mmap pd rtd tr txt v86 && return + ;; +esac + +return 1 diff --git a/Completion/Unix/Command/_mail b/Completion/Unix/Command/_mail index 90c75359d..d618cf366 100644 --- a/Completion/Unix/Command/_mail +++ b/Completion/Unix/Command/_mail @@ -1,9 +1,9 @@ #compdef mail mailx=mail Mail=mail mush zmail nail=mail _arguments -s \ - '(-f -u)*-b[specify a BCC recipient]:BCC recipient:->userhost' \ - '(-f -u)*-c[specify a CC recipient]:CC recipient:->userhost' \ + '(-f -u)*-b[specify a BCC recipient]:BCC recipient:_email_addresses -n $service' \ + '(-f -u)*-c[specify a CC recipient]:CC recipient:_email_addresses -n $service' \ '(-b -c -u -s *)-f+[specify mail folder]:mailbox:_mailboxes' \ - '(-f -u)-s+[specify a subject]:subject:' \ + '(-f -u)-s+[specify a subject]:subject' \ "(-b -c -f -s *)-u+[read specified user's mail]:user:_users" \ "(-f -u)*:recipient:_email_addresses -n $service" diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index e5a513f64..225c0af85 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -64,18 +64,18 @@ _make-parseMakefile () { while read input do case "$input " in - # VARIABLE = value - ([[:alnum:]][[:alnum:]_]#[ $TAB]#=*) - var=${input%%[ $TAB]#=*} + # VARIABLE = value OR VARIABLE ?= value + ([[:alnum:]][[:alnum:]_]#[ $TAB]#(\?|)=*) + var=${input%%[ $TAB]#(\?|)=*} val=${input#*=} val=${val##[ $TAB]#} VARIABLES[$var]=$val ;; - # VARIABLE := value + # VARIABLE := value OR VARIABLE ::= value # Evaluated immediately - ([[:alnum:]][[:alnum:]_]#[ $TAB]#:=*) - var=${input%%[ $TAB]#:=*} + ([[:alnum:]][[:alnum:]_]#[ $TAB]#:(:|)=*) + var=${input%%[ $TAB]#:(:|)=*} val=${input#*=} val=${val##[ $TAB]#} val=$(_make-expandVars $val) diff --git a/Completion/Unix/Command/_md5sum b/Completion/Unix/Command/_md5sum index 2351d1abd..c881a4e6d 100644 --- a/Completion/Unix/Command/_md5sum +++ b/Completion/Unix/Command/_md5sum @@ -1,10 +1,13 @@ -#compdef md5sum +#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]' \ + '(-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]' \ diff --git a/Completion/Unix/Command/_metaflac b/Completion/Unix/Command/_metaflac index 14095e9f9..65b9eb292 100644 --- a/Completion/Unix/Command/_metaflac +++ b/Completion/Unix/Command/_metaflac @@ -1,16 +1,13 @@ #compdef metaflac local _metaflac_opts _metaflac_shorts _metaflac_opers -typeset -A opt_args -function _metaflac_tags () { - echo "\n\nBEEP - $line - BEEP\n\n" -} -_metaflac_opts=( - '--preserve-modtime' - '--with-filename[prefix output with filename]' - '--no-filename' + +_metaflac_opts=( + '--preserve-modtime' + '--with-filename[prefix output with filename]' + '--no-filename' '--no-utf8-convert' - '--dont-use-padding[always rewrite the file]' + '--dont-use-padding[always rewrite the file]' ) _metaflac_shorts=( '--show-md5sum' @@ -23,7 +20,7 @@ _metaflac_shorts=( '--show-bps' '--show-total-samples' '--show-vendor-tag' - '--show-tag=:FLAC tags:_metaflac_tags' + '--show-tag=:FLAC tags' '--remove-tag=:FLAC tags: ' '--remove-first-tag=:FLAC tags: ' '--remove-all-tags' @@ -51,9 +48,7 @@ _metaflac_opers=( _arguments "$_metaflac_opts[@]" \ "*:FLAC file:_files -g \*.flac\(-.\)" \ - - "shortcuts" \ + - "shortcuts" \ "$_metaflac_shorts[@]" \ - - "(operations)" \ - "$_metaflac_opers[@]" \ - && return 0 - + - "(operations)" \ + "$_metaflac_opers[@]" diff --git a/Completion/Unix/Command/_mkdir b/Completion/Unix/Command/_mkdir index b5f75198f..f2299f7c7 100644 --- a/Completion/Unix/Command/_mkdir +++ b/Completion/Unix/Command/_mkdir @@ -1,33 +1,23 @@ -#compdef mkdir +#compdef mkdir gmkdir zf_mkdir -local curcontext="$curcontext" line state \ - args args_zsh args_cmd variant expl ret=1 -typeset -a opt_args +local curcontext="$curcontext" state line expl args variant ret=1 +typeset -A opt_args args=( '(-m --mode)'{-m,--mode=}'[set permission mode]:numeric mode' '(-p --parents)'{-p,--parents}'[make parent directories as needed]' - ) - -args_zsh=('(-)*: :->directories') - -args_cmd=( - '(-v --verbose)'{-v,--verbose}'[print message for each created directory]' - '(- :)--help[display help information]' - '(- :)--version[display version information]' - '*: :->directories' - ) + '(-)*: :->directories' +) case "$OSTYPE" in linux*) - args_cmd=( + args+=( '(-Z --context)'{-Z,--context=}'[set SELinux context]:SELinux context' - $args_cmd) - ;; + ) + ;; esac -_pick_variant -r variant gnu=gnu zsh='\(eval\)' unix --help - +_pick_variant -r variant gnu=gnu zsh='\(eval\)' $OSTYPE --help # It can still happen that there is a precommand command or builtin in the line. # In such cases, the variant has to be modified suitably, after further checking # the variant of the _command_ mkdir. @@ -44,26 +34,34 @@ _pick_variant -r variant gnu=gnu zsh='\(eval\)' unix --help # variant=zsh # fi -if [[ $variant == zsh ]]; then - args+=($args_zsh) -else - args+=($args_cmd) -fi - -# remove long options? -[[ $variant != gnu ]] && args=( ${${${args:#(|*\))--*}//--[^ )]#/}/\( #\)/} ) +case $variant in + gnu|freebsd*|dragonfly*) + args+=( + '(-v --verbose)'{-v,--verbose}'[print message for each created directory]' + ) + ;| + gnu) + args+=( + '(- :)--help[display help information]' + '(- :)--version[display version information]' + ) + ;; + zsh) # remove all options + args=( '*: :->directories' ) + ;; + *) # non-GNU: remove long options + args=( ${${${args:#(|*\))--*}//--[^ )]#/}/\( #\)/} ) + ;; +esac _arguments -C -s $args && ret=0 case "$state" in directories) - if (( $ret )) && [[ ! -prefix - ]] || \ - [[ $variant == zsh && ${#${${words[2,-1]}:#-*}} -gt 0 ]]; then - _wanted directories expl \ - 'parent directory (alternatively specify name of directory)' \ - _path_files -/ && ret=0 || _message 'name of directory' - fi - ;; + _wanted directories expl \ + 'parent directory (alternatively specify name of directory)' \ + _path_files -/ && ret=0 + ;; esac return ret diff --git a/Completion/Unix/Command/_module b/Completion/Unix/Command/_module index c1c9f5c08..060f05b86 100644 --- a/Completion/Unix/Command/_module +++ b/Completion/Unix/Command/_module @@ -52,9 +52,9 @@ _module() ) if (( CURRENT == 1 )); then - _describe -t commands 'module command' _module_cmds || compadd "$@" + _describe -t commands 'module command' _module_cmds else - local curcontext="$curcontext" + local curcontext="$curcontext" ret cmd="${${_module_cmds[(r)$words[1]:*]%%:*}}" # Deal with any aliases @@ -65,7 +65,7 @@ _module() show) cmd="display";; keyword) cmd="apropos";; esac - + if (( $#cmd )); then local update_policy @@ -132,7 +132,7 @@ _module_available_modules() { _arguments -s \ '(-a --append)'{--append,-a}'[append the directories instead of prepending]' \ - '*:directory:_files -/' + '*:directory:_files -/' } # Completion function for unuse diff --git a/Completion/Unix/Command/_monotone b/Completion/Unix/Command/_monotone index 83e18e306..bcaab87f0 100644 --- a/Completion/Unix/Command/_monotone +++ b/Completion/Unix/Command/_monotone @@ -1,8 +1,22 @@ #compdef mtn -local context state line ret -typeset -a cmds -typeset -A opt_args +local -a cmds +cmds=( + automate:automation db:database fdiff:debug fload:debug fmerge:debug + get_roster:debug identify:debug rcs_import:debug annotate:informative + cat:informative complete:informative diff:informative help:informative + list:informative log:informative ls:informative show_conflicts:informative + status:informative cert:key+cert chkeypass:key+cert dropkey:key+cert + genkey:key+cert trusted:key+cert pull:network push:network serve:network + sync:network privkey:packet\ i/o pubkey:packet\ i/o read:packet\ i/o + cvs_import:rcs approve:review comment:review disapprove:review tag:review + testresult:review checkout:tree co:tree explicit_merge:tree heads:tree + merge:tree merge_into_dir:tree migrate_workspace:tree propagate:tree + refresh_inodeprints:tree setup:tree set:vars unset:vars add:workspace + attr:workspace ci:workspace commit:workspace drop:workspace mv:workspace + pivot_root:workspace pluck:workspace rename:workspace revert:workspace + rm:workspace update:workspace +) _arguments \ '--brief[print a brief version of the normal output]' \ @@ -25,17 +39,5 @@ _arguments \ '--ticker[set ticker style]:ticker style:(count dot none)' \ '--version[print version number, then exit]' \ '(-@ --xargs)'{-@,--xargs}'[insert command line arguments taken from the given file]:file:_files' \ - '*:command:->cmd' && return 0 - -case "$state" in - (cmd) - if (( CURRENT == 2 )); then - cmds=(automate:automation db:database fdiff:debug fload:debug fmerge:debug get_roster:debug identify:debug rcs_import:debug annotate:informative cat:informative complete:informative diff:informative help:informative list:informative log:informative ls:informative show_conflicts:informative status:informative cert:key+cert chkeypass:key+cert dropkey:key+cert genkey:key+cert trusted:key+cert pull:network push:network serve:network sync:network privkey:packet\ i/o pubkey:packet\ i/o read:packet\ i/o cvs_import:rcs approve:review comment:review disapprove:review tag:review testresult:review checkout:tree co:tree explicit_merge:tree heads:tree merge:tree merge_into_dir:tree migrate_workspace:tree propagate:tree refresh_inodeprints:tree setup:tree set:vars unset:vars add:workspace attr:workspace ci:workspace commit:workspace drop:workspace mv:workspace pivot_root:workspace pluck:workspace rename:workspace revert:workspace rm:workspace update:workspace) - _describe -t commands 'cmds' cmds && ret=0 - else - _files - fi - ;; -esac - -return ret + '1:command: _describe -t commands command cmds' \ + '*:file:_files' diff --git a/Completion/Unix/Command/_mosh b/Completion/Unix/Command/_mosh index dacbd1018..c19f6ebde 100644 --- a/Completion/Unix/Command/_mosh +++ b/Completion/Unix/Command/_mosh @@ -1,9 +1,8 @@ #compdef mosh local curcontext="$curcontext" state line -local -a suf -_arguments \ +_arguments -C \ '(-)--help[display help information]' \ '(-)--version[display version information]' \ "--no-init[don't set terminal init string]" \ diff --git a/Completion/Unix/Command/_mount b/Completion/Unix/Command/_mount index 04282225f..a3b58bb87 100644 --- a/Completion/Unix/Command/_mount +++ b/Completion/Unix/Command/_mount @@ -959,27 +959,9 @@ udevordir) esac local MATCH MBEGIN MEND - # "Mummy, why is mount point matching full of squiggles?" - # - # "Well, dear, the clever people who wrote Linux decided that some - # funny characters that might confuse programmes looking at the names - # would be encoded as octal escapes, like for example \040 for space. - # The clever people who wrote zsh decided that nothing would - # ever be quite as simple as it should be, so to substitute octal - # escapes everywhere in a string, even though the shell understands - # them natively in print escapes, needs some hackery where you match - # the octal number using the numeric closure syntax introduced after - # 4.3.4, then reinput the number in a standard math mode format as 8#OOO, - # and turn that into a character using the (#) parameter flag." - # - # "Mummy, why is nothing ever quite as simple as it should be?" - # - # "Well, dear, if it was then the clever people who write programmes would - # have been replaced by intelligent monkeys and then they'd be out - # of working roaming the streets, and we wouldn't want that, would we?" - mp_tmp=("${(@q)mp_tmp//(#m)\\[0-7](#c3)/${(#)$(( 8#${MATCH[2,-1]} ))}}") - dpath_tmp=( "${(@Mq)dev_tmp:#/*}" ) - dev_tmp=( "${(@q)dev_tmp:#/*}" ) + mp_tmp=("${(@qg::)mp_tmp}") + dpath_tmp=( "${(@Mqg::)dev_tmp:#/*}" ) + dev_tmp=( "${(@qg::)dev_tmp:#/*}" ) _alternative \ 'device-labels:device label:compadd -a dev_tmp' \ diff --git a/Completion/Unix/Command/_mpc b/Completion/Unix/Command/_mpc index 12707677f..11eab8463 100644 --- a/Completion/Unix/Command/_mpc +++ b/Completion/Unix/Command/_mpc @@ -68,21 +68,21 @@ _mpc_command() { ) if (( CURRENT == 1 )); then - _describe -t command "mpc commands" mpc_cmds + _describe -t commands "mpc command" mpc_cmds else - local curcontext="$curcontext" + local cmd=$words[1] + local curcontext="${curcontext%:*}:mpc-${cmd}" ret=1 + if ! _call_function ret _mpc_$cmd; then + _default && ret=0 + fi + return ret fi - - local cmd=$words[1] - - local curcontext="${curcontext%:*}:mpc-${cmd}" - _call_function ret _mpc_$cmd } _mpc_helper_bool() { local expl states states=(on off yes no 1 0 true false) - _wanted states expl boolean compadd $expl -a states + _wanted states expl boolean compadd -a states } (( $+functions[_mpc_helper_songnumbers] )) || @@ -100,7 +100,7 @@ _mpc_helper_songnumbers() { NM="$compstate[nmatches]" fi - out=("${(@f)$(_call_program song-numbers mpc $foo playlist 2>/dev/null)}") + out=("${(@f)$(_call_program song-numbers mpc $foo playlist)}") out=("${(@M)out[@]:#${~MATCH}}") sn=("${(@)${(@M)out}//(#b)(#s)(\#|[ >]#)([0-9]#)*/$match[2]}") diff --git a/Completion/Unix/Command/_mtr b/Completion/Unix/Command/_mtr index f4df5b3cf..5eda9bc1a 100644 --- a/Completion/Unix/Command/_mtr +++ b/Completion/Unix/Command/_mtr @@ -4,13 +4,19 @@ _arguments -C \ '(-h --help)'{-h,--help}'[help]' \ '(-v --version)'{-v,--version}'[version]' \ '(-r --report)'{-r,--report}'[report mode]' \ + '(-w --report-wide)'{-w,--report-wide}'[wide report mode\: do not truncate hostnames]' \ '(-c --report-cycles)'{-c,--report-cycles}'[report cycles]:number of pings' \ - '(-p --psize)'{-p,--psize}'[packet size]:number of bytes' \ + '(-s --psize)'{-s,--psize}'[packet size]:number of bytes' \ '(-t --curses)'{-t,--curses}'[curses UI]' \ + '(-e --mpls)'{-e,--mpls}'[display ICMP MPLS information]' \ + '(-o --order)'{-o,--order}'[order output fields]:fields order' \ '(-n --no-dns)'{-n,--no-dns}'[no DNS lookups]' \ '(-g --gtk)'{-g,--gtk}'[GTK+ UI]' \ - '(-s --split)'{-s,--split}'[output for a split-user interface]' \ + '(-p --split)'{-p,--split}'[output for a split-user interface]' \ '(-l --raw)'{-l,--raw}'[raw output format]' \ '(-a --address)'{-a,--address}'[source address]:source IP:_hosts' \ '(-i --interval)'{-i,--interval}'[ping interval]:number of seconds' \ + '-u[use UDP instead of ICMP echo]' \ + '-4[use IPv4 only]' \ + '-6[use IPv6 only]' \ ':destination host:_hosts' diff --git a/Completion/Unix/Command/_mysqldiff b/Completion/Unix/Command/_mysqldiff index 094694d32..4b46c86df 100644 --- a/Completion/Unix/Command/_mysqldiff +++ b/Completion/Unix/Command/_mysqldiff @@ -1,8 +1,5 @@ #compdef mysqldiff -local curcontext="$curcontext" state line expl -typeset -A opt_args - _mysqldiff () { _arguments -s \ {-h{,1,2},--host{,1,2}=}':server hostname:_mysql_hosts' \ diff --git a/Completion/Unix/Command/_netcat b/Completion/Unix/Command/_netcat index 396fc8e09..4e4006b30 100644 --- a/Completion/Unix/Command/_netcat +++ b/Completion/Unix/Command/_netcat @@ -1,11 +1,10 @@ #compdef nc netcat -local curcontext="$curcontext" state line expl -typeset -A opt_args - # handle name clash with the nedit client -[[ $service = nc ]] && ! _pick_variant netcat=connect nedit -h && - _nedit && return +if [[ $service = nc ]] && ! _pick_variant netcat=connect nedit -h; then + _nedit + return +fi if (( ! $+_nc_args )); then local help="$(_call_program options $words[1] -h < /dev/null 2>&1)" @@ -14,17 +13,17 @@ if (( ! $+_nc_args )); then '*-e prog*' '-e+[program to exec after connect]:prog:_command_names -e' '*-g gateway*' '-g+[source-routing hop point]:gateway:_hosts' '*-G num*' '-G[source-routing pointer: 4, 8, 12]' - '*-i secs*' '-i+[delay interval for lines sent or ports scanned]:secs:' + '*-i secs*' '-i+[delay interval for lines sent or ports scanned]:delay (secs)' '*-l*' '-l[listen mode]' '*-n*' '-n[numeric-only IP addresses, no DNS]' '*-o file*' '-o+[hex dump of traffic]:file:_files' '*-p port*' '-p+[local port number]:port:_ports' '*-r*' '-r[randomize local and remote ports]' - '*-q secs*' '-q+[quit after EOF on stdin and delay of secs]:secs:' + '*-q secs*' '-q+[quit after EOF on stdin and delay of secs]:delay (secs)' '*-t*' '-t[answer TELNET negotiation]' '*-u*' '-u[UDP mode]' '*-v*' '-v[verbose]' - '*-w secs*' '-w+[timeout for connects and final net reads]:secs:' + '*-w secs*' '-w+[timeout for connects and final net reads]:timeout (secs)' '*-z*' '-z[zero-I/O mode]' '*-x*' '-x' '*-b*' '-b[allow broadcasts]' @@ -32,7 +31,7 @@ if (( ! $+_nc_args )); then _nc_args=($optionmap[(K)"$help"]) fi -_arguments -C -s \ +_arguments -s \ "$_nc_args[@]" \ ':host:_hosts' \ - ':port:_ports' && return 0 + ':port:_ports' diff --git a/Completion/Unix/Command/_nl b/Completion/Unix/Command/_nl new file mode 100644 index 000000000..b3876dc65 --- /dev/null +++ b/Completion/Unix/Command/_nl @@ -0,0 +1,40 @@ +#compdef nl gnl + +local curcontext="$curcontext" state line args ret=1 + +args=( + '(-b --body-numbering)'{-b+,--body-numbering=}'[specify style for body lines]:style:->styles' + '(-d --section-delimiter)'{-d+,--section-delimiter=}'[separate logical pages with specified delimiter]:delimiter' + '(-f --footer-numbering)'{-f+,--footer-numbering=}'[specify style for footer lines]:style:->styles' + '(-h --header-numbering)'{-h+,--header-numbering=}'[specify style for header lines]:style:->styles' + '(-i --line-increment)'{-i+,--line-increment=}'[line number increment at each line]:increment' + '(-l --join-blank-lines)'{-l+,--join-blank-lines=}'[count consecutive empty lines as one]:number' + '(-n --number-format)'{-n+,--number-format=}'[specify format for line numbers]:format:((ln\:left\ justified rn\:right\ justified rz\:right\ justified\ with\ leading\ zeroes))' + '(-p --no-renumber)'{-p,--no-renumber}"[don't reset line numbers at logical pages]" + '(-s --number-separator)'{-s+,--number-separator=}'[add specified string after line numbers]:string' + '(-v --starting-line-number)'{-v+,--starting-line-number=}'[specify first line number on each logical page]:initial number' + '(-w --number-width)'{-w+,--number-width=}'[specify number of columns for line numbers]:columns' +) + +if _pick_variant gnu=GNU unix --version; then + args+=( + '(- *)--help[display help information]' + '(- *)--version[display version information]' + ) +else + args=( ${(R)args:#(|\*)(|\(*\))--*} ) # remove long options +fi + +_arguments -C -s $args '*:file:_files' && ret=0 + +if [[ -n $state ]]; then + if compset -P p; then + _message -e regex 'regular expression' + else + _describe -t styles style '( p:number\ only\ lines\ matching\ regex )' -S '' -- '( + a:number\ all\ lines + t:number\ only\ non-empty\ lines + n:no\ line\ numbering + )' + fi +fi || return ret diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm index 6c95a0d85..80136329d 100644 --- a/Completion/Unix/Command/_nm +++ b/Completion/Unix/Command/_nm @@ -1,12 +1,12 @@ -#compdef nm +#compdef nm eu-nm -local args files +local args files variant _nm_object_file() { - [[ -x $REPLY || $REPLY = *.([ao]|so) ]] + [[ -x $REPLY || $REPLY = *.([ao]|so|elf) ]] } -files="*:object file:_path_files -g '*(-.e:_nm_object_file:)'" +files="*:object file:_files -g '*(-.e:_nm_object_file:)'" args=( '(-A -o --print-file-name)'{-A,-o,--print-file-name}'[print name of input file on each line]' '(--demangle)-C[decode symbol names]' @@ -15,7 +15,7 @@ args=( '(-t --radix -o -x)'{-t,--radix}'[specify radix for numeric values]:radix:((d\:decimal o\:octal x\:hexadecimal))' ) -if _pick_variant gnu=GNU unix -V; then +if _pick_variant -r variant binutils=GNU elftoolchain=elftoolchain elfutils=elfutils unix -V; then compset -P '@' && files='*:options file:_files' args+=( '(- *)--help[display help information]' @@ -24,22 +24,47 @@ if _pick_variant gnu=GNU unix -V; then '(-C --no-demangle)--demangle=-[decode symbol names]::style:(auto gnu lucid arm hp edg gnu-v3 java gnat)' "(-C --demangle)--no-demangle[don't decode symbol names]" '(-u --undefined-only)--defined-only[display only defined symbols]' - '(-f --format -P)'{-f+,--format=}'[specify output format]:format:(bsd sysv posix)' - '(-l --line-numbers)'{-l,--line-numbers}'[display source file and line numbers from debug information]' - '(-n --numeric-sort -p --no-sort --size-sort)'{-n,--numeric-sort}'[sort symbols numerically by address]' + '(-f --format -P)--format=[specify output format]:format:(bsd sysv posix)' + '(-n --numeric-sort -p --no-sort --size-sort -v)'{-n,--numeric-sort}'[sort symbols numerically by address]' '(-p --no-sort -n --numeric-sort -r -P --reverse-sort --size-sort)'{-p,--no-sort}'[do not sort symbols]' '(-P --portability -B -f --format)'{-P,--portability}'[same as --format=posix]' - '(-r --reverse-sort -p --no-sort --size-sort)'{-r,--reverse-sort}'[reverse sort order]' - '--plugin[load specified plugin]:plugin' + '(-r --reverse-sort -p --no-sort --size-sort -v)'{-r,--reverse-sort}'[reverse sort order]' '(-u --undefined-only --defined-only)'{-u,--undefined-only}'[display only undefined symbols]' - "--target=[target object format]:targets:(${${(@M)${(f)$(_call_program targets nm --help)}:#*supported targets:*}##*: })" '(-a --debug-syms)'{-a,--debug-syms}'[display debugger-only symbols]' '(-S --print-size)'{-S,--print-size}'[print size of defined symbols]' '(-s --print-armap)'{-s,--print-armap}'[include index for symbols from archive members]' - '(-p --no-sort -n --numeric-sort -r)--size-sort[sort symbols by size]' - '--special-syms[include special symbols in the output]' - '--synthetic[display synthetic symbols as well]' + '(-p --no-sort -n --numeric-sort -r -v)--size-sort[sort symbols by size]' ) + case $variant in + elftoolchain|binutils) + args+=( + '(-l --line-numbers)'{-l,--line-numbers}'[display source file and line numbers from debug information]' + ) + ;| + elftoolchain) + args=( ${args:#*--(portability|extern-only)\[*} + '(- *)-h[display help information]' + '(-t -x)-o[print values in octal]' + '(-t -o)-x[print values in hexadecimal]' + '(--size-sort)-v[sort output by value]' + ) + ;; + elfutils) + args+=( + '--mark-special[mark special symbols]' + '--color=[use color in output]:color:(always auto never)' + ) + ;; + binutils) + args+=( + '(-f --format -P)-f+[specify output format]:format:(bsd sysv posix)' + '--plugin[load specified plugin]:plugin' + '--special-syms[include special symbols in the output]' + '--synthetic[display synthetic symbols as well]' + "--target=[target object format]:targets:(${${(@M)${(f)$(_call_program targets nm --help)}:#*supported targets:*}##*: })" + ) + ;; + esac else # following flags are accurate for Solaris args=( ${args:#(|*\)(\*|))-[o-]*} diff --git a/Completion/Unix/Command/_notmuch b/Completion/Unix/Command/_notmuch index b576d2b29..d6cc58deb 100644 --- a/Completion/Unix/Command/_notmuch +++ b/Completion/Unix/Command/_notmuch @@ -57,12 +57,15 @@ _notmuch_search() _notmuch() { + local ret=1 if (( CURRENT > 2 )) ; then local cmd=${words[2]} curcontext="${curcontext%:*:*}:notmuch-$cmd" (( CURRENT-- )) shift words - _call_function ret _notmuch_$cmd + if ! _call_function ret _notmuch_$cmd; then + _default && ret=0 + fi return ret else _notmuch_commands diff --git a/Completion/Unix/Command/_od b/Completion/Unix/Command/_od index d542597e0..db75b3f96 100644 --- a/Completion/Unix/Command/_od +++ b/Completion/Unix/Command/_od @@ -1,6 +1,6 @@ -#compdef od +#compdef od god -local context state state_descr line args ret=1 +local curcontext="$curcontext" state state_descr line args ret=1 local -A opt_args args=( @@ -19,13 +19,14 @@ args=( {-l,-I,-L}'[output decimal longs (-t dL)]' {-o,-B}'[output octal shorts (-t o2)]' '-s[output decimal shorts (-t d2)]' - '*:files:_files' ) if _pick_variant gnu=GNU unix --version; then # -h -B -I and -L are obsolescent and undocumented args=( ${(R)args:#(|\*)(|\(*\))-[hBIL]*} ) args+=( + '--traditional' + '--endian=[swap input bytes]:endianess:(big little)' {-S+,--strings=-}'[output strings of at least specfied bytes long]:length' {-w-,--width=-}'[output specified bytes per line]:bytes' '(- : *)--help[display help and exit]' @@ -34,22 +35,33 @@ if _pick_variant gnu=GNU unix --version; then else args=( ${(R)args:#(|\*)(|\(*\))--*} ) # remove long options case "$OSTYPE" in - (darwin*|freebsd*|dragonfly*|openbsd*) + darwin*|freebsd*|dragonfly*|openbsd*) args+=( - '-D[output unsigned decimal ints (-t u4)]' + '-D[output unsigned decimal integers (-t u4)]' {-e,-F}'[output double-precision floats (-t fD)]' {-H,-X}'[output hexadecimal ints (-t x4)]' '-O[output octal ints (-t o4)]' ) - ;; + ;; + solaris*) + args=( + ${(M)args:#(|\*)(|\(*\))-[AjNtvbcdfosx]*} + '-C[output all printable characters and use C-style escapes]' + '-D[output unsigned decimal long words (-t u4)]' + '-F[output double-precision floats (-t f8)]' + '-O[output octal ints (-t o4)]' + '-S[output decimal ints (-t d4)]' + '-X[output hexadecimal ints (-t x4)]' + ) + ;; (*) # POSIX options only args=( ${(M)args:#(|\*)(|\(*\))-[AjNtvbcdosx]*} ) - ;; + ;; esac fi -_arguments -s -S : "$args[@]" && return 0 +_arguments -C -s -S : "$args[@]" '*:files:_files' && return 0 case "$state" in (format) diff --git a/Completion/Unix/Command/_patch b/Completion/Unix/Command/_patch index add436702..c0df00c00 100644 --- a/Completion/Unix/Command/_patch +++ b/Completion/Unix/Command/_patch @@ -1,7 +1,7 @@ -#compdef patch +#compdef patch gpatch if (( ! $+_patch_args )); then - local help="$(LC_ALL=C patch --help 2>&1)" + local help="$(LC_ALL=C $words[1] --help 2>&1)" local -A optionmap local arg local comp_p='compadd "$expl[@]" -S0 -r "1-9" - ""' diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep index 95d0ea284..3af55a379 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -1,6 +1,6 @@ #compdef pgrep pkill -local context state line ret=1 expl +local curcontext="$curcontext" state line ret=1 expl typeset -A opt_args typeset -a arguments @@ -66,7 +66,7 @@ esac arguments=( ${(M)arguments:#(|\*)(|\(*\))-[$optchars]*} '*:process name:->pname') -_arguments -s -w $arguments && ret=0 +_arguments -C -s -w $arguments && ret=0 case $state in (tty) diff --git a/Completion/Unix/Command/_ping b/Completion/Unix/Command/_ping index e59f6fa9f..a1a50e11f 100644 --- a/Completion/Unix/Command/_ping +++ b/Completion/Unix/Command/_ping @@ -33,31 +33,37 @@ if _pick_variant iputils=iputils unix -V; then else -# FreeBSD 4.11 - _arguments \ '-A[audible for no packet]' \ - '-Q[somewhat quiet]' \ - '-R[record route]' \ '-a[audible for each packet]' \ + '-c:count' \ + "-D[set the don't fragment bit]" \ '-d[set SO_DEBUG on the socket]' \ '-f[flood ping]' \ - '-n[numeric output only]' \ - '-q[quiet]' \ - '-r[bypass normal routing tables]' \ - '-v[verbose]' \ - '-c:count' \ + '-G[specify maximum size for ICMP payload for sweeping pings]:size' \ + '-g[specify minimum size for ICMP payload for sweeping pings]:size [0]' \ + '-h[specify size increment for ICMP payload for sweeping pings]:size [1]' \ '-i:wait seconds' \ + '-I[source interface for multicast packets]:iface:_net_interfaces' \ + '-L[suppress loopback of multicast packets]' \ '-l:preload number' \ + '-M:icmp:(mask time)' \ '-m:ttl' \ - '-p:padding pattern' \ + '-n[numeric output only]' \ + '-o[exit after receiving one packet]' \ '-P:IPsec policy' \ + '-p:padding pattern' \ + '-Q[somewhat quiet]' \ + '-q[quiet]' \ + '-R[record route]' \ + '-r[bypass normal routing tables]' \ + '-S:source address' \ '-s:packet size in bytes' \ - '-S:src addr' \ - '-t:timeout in seconds' \ - '-L[suppress loopback of multicast packets]' \ - '-I:iface:_net_interfaces' \ '-T:ttl for multicasted packets' \ + '-t:timeout in seconds' \ + '-v[verbose]' \ + '-W:wait time (ms)' \ + '-z:type of service' \ ':host:_hosts' fi diff --git a/Completion/Unix/Command/_pkg-config b/Completion/Unix/Command/_pkg-config index 48b788a1b..e44b36897 100644 --- a/Completion/Unix/Command/_pkg-config +++ b/Completion/Unix/Command/_pkg-config @@ -1,6 +1,6 @@ #compdef pkg-config -local arguments packages curcontext="$curcontext" stat line +local arguments packages curcontext="$curcontext" state line ret=1 declare -A opt_args arguments=( @@ -11,31 +11,33 @@ arguments=( "--print-errors[cause errors to be printed]" "--silence-errors[prevent the printing of errors]" "--errors-to-stdout[print errors to stdout rather than stderr]" - "--cflags[prints the preprocessor and compile flags]" + "--cflags[print the preprocessor and compiler flags]" "--cflags-only-I[output -I flags only]" "--cflags-only-other[output cflags not covered by the cflags-only-I option]" "--debug[show verbose debug information]" - "--libs[prints the link flags]" - "--libs-only-L[prints the -L and -R parts of \"--libs\"]" - "--libs-only-l[prints the -l part of \"--libs\"]" + "--libs[print the link flags]" + "--libs-only-L[print the -L and -R parts of \"--libs\"]" + "--libs-only-l[print the -l part of \"--libs\"]" "--libs-only-other[output other libs]" "--list-all[list all known packages]" "--variable=[return the value of the specified variable]:variable" "--define-variable=[set the global value for a variable]:name value pair" - "--uninstalled[return successfully if any \"-uninstalled\" packages are being used and fails otherwise]" - "--exists[tests whether the package exists or not]" + "--uninstalled[return success if any \"-uninstalled\" packages are being used]" + "--exists[test whether the package exists or not]" "--atleast-version=[test whether the version is at least that of the specified value]:least value" "--exact-version=[test whether the version is exactly that of the specified value]:exact value" "--max-version=[test whether the version is no greater than some specific value]:max version" # "--msvc-syntax[output linker flags in a form compatible with MSVC++ (Windows only)]" # "--dont-define-prefix[disables automatic overiding of the variable \"prefix\" (Windows only)]" # "--prefix-variable=[set the name of the variable \"prefix\" (Windows only)]:prefix value" - "*:package name:->package" + "*: :->packages" ) -_arguments -C $arguments +_arguments -C $arguments && ret=0 if [[ -n $state ]] ; then - packages=( ${(f)"$((pkg-config --list-all | cut -d' ' -f1) 2>/dev/null)"} ) - compadd -a - packages + packages=( ${${(f)"$(_call_program packages pkg-config --list-all)"}%% *} ) + _wanted packages expl 'package' compadd -a - packages && ret=0 fi + +return ret diff --git a/Completion/Unix/Command/_prove b/Completion/Unix/Command/_prove index 75e83c360..1f21423e6 100644 --- a/Completion/Unix/Command/_prove +++ b/Completion/Unix/Command/_prove @@ -45,7 +45,7 @@ _arguments \ '--source=[load or configure a SourceHandler]:source:' \ {-a,--archive}'[store output in archive file]:file:_files' \ {-j,--jobs}'[run N jobs in parallel]:jobs:' \ - '*--state=[control persistent state]:state:' \ + '*--state=[control persistent state]: :_values -s , state last failed passed all hot todo slow fast new old fresh save' \ '--rc=[custom rcfile]:file:_files' \ - '*:file or directory:_files' \ - && return 0 + '*--rules=[limit tests run (or not) in parallel]:rules' \ + '*:file or directory:_files' diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps new file mode 100644 index 000000000..925f48390 --- /dev/null +++ b/Completion/Unix/Command/_ps @@ -0,0 +1,188 @@ +#compdef ps + +_ps_props() { + local opts + + if [[ $1 = -s ]]; then + shift + compset -P '[+-]' || _describe -t modifiers modifier \ + '( +:ascending\ order -:descending\ order )' -S '' + fi + + case $OSTYPE in + linux-gnu) opts=( ${${(f)"$(_call_program properties $words[1] L)"}%% *} ) ;; + freebsd*) opts=( $(_call_program properties $words[1] L) ) ;; + solaris*) opts=( ${=${(f)"$(_call_program properties $words[1] - 2>&1)"}[-3,-1]} ) ;; + esac + + compadd "$@" -a opts +} + +local curcontext="$curcontext" state line expl ret=1 +local short long +local -a args bsd bsdarg pids +local -A equivs + +args=( + '-a[select processes with tty except session leaders]' + {-A,-e}'[select every process]' + '-d[select all processes except session leaders]' + '*-p+[select processes by ID]:process ID:_sequence -s , _pids' + '*-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 , compadd - /dev/pts/<->(N\:s/\\/dev\\//) /dev/tty*(N\:t)' + '*-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 -' + + '-c[show scheduler properties]' + '-f[full listing]' + '-j[show session ID and process group ID]' + '-l[long listing]' + '-L[show information about each light weight process]' + '-y[show RSS in place of ADDR (used with -l)]' +) + +bsd=( + 'a[include processes belonging to other users]' + 'e[show environment after command]' + '(j s u v X)l[output in long format]' + '(l s u v X)j[output in job control format]' + 'x[include processes with no controlling terminal]' + '(j l s v X)u[output in resource usage format]' + '(j l s u X)v[output in virtual memory format]' + '*w[wide output]' + 'H[show threads as if they were processes]' + 'L[display all format specifiers]' + 'S[include child process data with the parent]' + 'T[select processes attached to current terminal]' + 'Z[show security data]' +) +bsdarg=( + '*p[select processes by ID]' + '*t[select processes by attached terminal]' + '*U[select processes by effective user]' + 'O[specify additional output fields]' + 'o[specify output format]' + 'N[set namelist file for WCHAN display]' +) + +case $OSTYPE in + solaris2.<11->) + args+=( + '-h[select processes homed to the specified lgrp]:lgrp list' + '-H[show home lgroup of the process]' + ) + ;| + solaris*) + args+=( + '-P[show processor to which the process or lwp is bound]' + '*-z[select processes by zone]:zone list:_sequence _zones' + '-Z[show zone with which process is associated]' + ) + ;; + darwin*|dragonfly*|freebsd*|netbsd*|openbsd*) + bsd+=( + 'A[select every process]' + 'C[ignore resident time for CPU percentage]' + 'c[show just executable name for command]' + 'h[repeat header lines, one per page of output]' + '(r)m[sort by memory usage]' + '(m)r[sort by CPU usage]' + ) + bsdarg+=( + 'M[extract values from specified core]' + ) + ;| + linux-gnu|netbsd*) bsdarg+=( 'k[specify sort order]' ) ;| + darwin*|freebsd*) bsdarg+=( 'G[select processes by real group]' ) ;| + freebsd*) + bsd+=( + 'd[show process hierarchy]' + 'f[show command and environment for swapped out processes]' + '*J[select processes by jail ID]' + ) + ;; + netbsd*) bsd+=( '(j l u v)s[output in thread format]' ) ;; + openbsd*) + bsd+=( + 'k[display information about kernel threads]' + ) + bsdarg+=( 'W[extract swap information from the specified file]' ) + ;; + linux-gnu) + args+=( + '-O+[specify additional output fields]:property:_sequence -s , _ps_props -' + '(-N --deselect)'{-N,--deselect}'[negate selection: all processes except those selected]' + '*-C[select processes by command name]:command:_sequence -s , _command_names -e' + '*--ppid[select processes by parent process ID]:parent process:_sequence -S , _pids' + '(-f)-F[extra full format listing]' + '--context[show SELinux security context format]' + '-M[show security data]' + '(--forest -H)'{--forest,-H}'[show process hierarchy]' + '--headers[repeat header lines, one per page of output]' + '(--cols --columns --width)'{--cols,--columns,--width}'[set screen width]:width' + '(--lines --rows)'{--lines,--rows}'[set screen height]' + '--cumulative[include child process data with the parent]' + '-n[set namelist file for WCHAN display]:file:_files' + '(--no-headers --no-heading)'{--no-headers,--no-heading}'[suppress headers]' + '--sort=[specify sort order]:order:_ps_props -s' + '-w[wide output]' + '-m[show threads after processes]' + '-T[show threads, with SPID column]' + '-Z[show security context format (SELinux)]' + '(- *)--help[display help information]::subject:(simple list output threads misc all)' + '(- *)--info[display debugging information]' + '(- *)'{-V,--version}'[display version information]' + ) + equivs=( G Group g group p pid s sid t tty U User u user o format ) + for short long in ${(kv)equivs}; do + args+=( ${${(M)args:#(\*|)-$short*}/$short+/-$long=} ) + done + bsd+=( + 'c[show true command name]' + 'f[show process hierarchy]' + 'h[suppress header]' + 'm[show threads after processes]' + 'n[numeric output for WCHAN and USER]' + 'r[select running processes]' + '(j l u v X)s[output in signal format]' + 'V[display version information]' + '(j l s u v)X[output in register format]' + ) + ;; +esac + +if (( CURRENT > 1 )) && [[ $OSTYPE != solaris* || ( $OSTYPE = linux-gnu && $words[CURRENT-1] != -* ) ]]; then + case $words[CURRENT-1] in + *k) + _wanted -C option-k-1 properties expl 'property' _sequence -s , _ps_props -s - && return + ;; + *G) _sequence -s , _groups && return ;; + *J) _sequence -s , _jails && return ;; + *[MNW]) _files && return ;; + *t) + _wanted -C option-t-1 ttys expl tty _sequence -s , \ + compadd - /dev/pts/<->(N\:s/\\/dev\\//) /dev/tty*(N\:t) && return + ;; + *p) _wanted -C option-p-1 processes expl 'process ID' _sequence -s , _pids && return;; + *U) _wanted -C option-U-1 users expl user _sequence -s , _users && return ;; + *[oO]) _wanted -C "option-${words[CURRENT-1][-1]}-1" properties \ + expl 'property' _sequence -s , _ps_props - && return ;; + esac +fi + +if [[ $OSTYPE = (*bsd*|darwin*|dragonfly*) ]]; then + compset -P - && pids=1 +else + _arguments -C -s $args '*:: :->rest' && ret=0 + [[ -z "$state" || $OSTYPE = solaris* ]] && return ret +fi + +_values -s '' -S ' ' 'options' $bsd && ret=0 +_values -S ' ' 'options' $bsdarg && ret=0 +if [[ -z $pids ]]; then + _pids && compstate[insert]= +fi +return ret diff --git a/Completion/Unix/Command/_pydoc b/Completion/Unix/Command/_pydoc index 92a01a76f..677c96ad6 100644 --- a/Completion/Unix/Command/_pydoc +++ b/Completion/Unix/Command/_pydoc @@ -1,16 +1,34 @@ -#compdef pydoc +#compdef -P pydoc[0-9.]# -local context state line +local curcontext=$curcontext state state_descr line ret=1 typeset -A opt_args +local -a args -_arguments \ - '-k[keyword]:keyword:' \ - '-p[port]:port:_ports' \ - '-g[gui]' \ - '-w[write out HTML]:file or dir:_files' \ - ':keyword, topic, module, package, or dotted reference:->lookup' && return 0 +args=( + '(- *)-k[search keyword]:keyword' + '(-k -g -w *)-p[start web server on specified port]:port number' + '(-)-w[write out HTML in current directory]' + '(-)*: :->lookup' +) -_alternative \ - 'keywords:keyword:compadd ${=${${(f)"$(pydoc keywords)"}[2,-1]}}' \ - 'topics:topic:compadd ${=${${(f)"$(pydoc topics)"}[2,-1]}}' \ - 'modules:module:' +if _pick_variant pydoc3='pydoc3 -b' pydoc2 -h; then + args+=( '(-k -w *)-b[start server and open browser]' ) +else + args+=( '(- *)-g[start gui]' ) +fi + +_arguments -C : $args && return 0 + +case $state in +(lookup) + if [[ $words[CURRENT] = */* ]]; then + _files && ret=0 + else + _alternative \ + 'keywords:keyword:compadd ${=${${(f)"$(_call_program keywords $words[1] keywords)"}[2,-1]}}' \ + 'topics:topic:compadd ${=${${(f)"$(_call_program topics $words[1] topics)"}[2,-1]}}' \ + 'modules:module:_python_modules' && ret=0 + fi +esac + +return ret diff --git a/Completion/Unix/Command/_python b/Completion/Unix/Command/_python index 8e32bdf55..dedb9ceda 100644 --- a/Completion/Unix/Command/_python +++ b/Completion/Unix/Command/_python @@ -1,11 +1,10 @@ -#compdef python python2 python2.4 python2.5 python2.6 python2.7 python3.0 python3.1 python3.2 python3.3 python3.4 +#compdef -P python[0-9.]# # Python 2.7 # Python 3.4 -local curcontext="$curcontext" state line expl +local curcontext="$curcontext" state state_descr line typeset -A opt_args - local -a args if _pick_variant python3=Python\ 3 python2 --version; then @@ -32,7 +31,7 @@ _arguments -C -s -S "$args[@]" \ '-E[ignore PYTHON* environment variables (such as PYTHONPATH)]' \ '(1 * -)-h[display help information]' \ '-i[inspect interactively after running script]' \ - '(1 -)-m[run library module as a script (terminates option list)]:module:->modules' \ + '(1 -)-m[run library module as a script (terminates option list)]:module:_python_modules' \ '-O[optimize generated bytecode slightly]' \ '-OO[remove doc-strings in addition to the -O optimizations]' \ "-s[don't add user site directory to sys.path]" \ @@ -46,14 +45,6 @@ _arguments -C -s -S "$args[@]" \ '*::script argument:= ->normal' && return case "$state" in - modules) - local -a modules - modules=( - ${${=${(f)"$(_call_program modules $words[1] -c \ - 'from\ pydoc\ import\ help\;\ help\(\"modules\"\)')"}[2,-3]}:#\(package\)} - ) - _wanted modules expl module compadd -a modules && return - ;; normal) if [[ -z "$opt_args[(I)-(c|m)]" ]]; then shift words diff --git a/Completion/Unix/Command/_rar b/Completion/Unix/Command/_rar index 1e3a26166..e2081f6e7 100644 --- a/Completion/Unix/Command/_rar +++ b/Completion/Unix/Command/_rar @@ -38,7 +38,7 @@ common=( case $service in unrar) if (( CURRENT == 2 )); then - _values 'rar command' \ + _values 'rar command' \ 'e[extract files to current directory]' \ 'l[list archive]' \ 'lt[list archive (technical format)]' \ @@ -48,7 +48,7 @@ case $service in 'v[verbosely list archive]' \ 'vt[verbosely list archive (technical format)]' \ 'vb[verbosely list archive (bare format)]' \ - 'x[extract files with full path]' && return + 'x[extract files with full path]' else _arguments -S \ '-ep3[expand paths to full including the drive letter]' \ @@ -58,7 +58,7 @@ case $service in '-n+:file to include:_files' \ '-n@+:file of files to include:_files' \ "$common[@]" \ - '*:RAR files:_files -g \*.rar\(-.\)' && return + '*:RAR files:_files -g \*.rar\(-.\)' fi ;; rar) @@ -89,7 +89,7 @@ case $service in 'v[verbosely list archive]' \ 'vt[verbosely list archive (technical format)]' \ 'vb[verbosely list archive (bare format)]' \ - 'x[extract files with full path]' && return + 'x[extract files with full path]' else _arguments -S \ '-ag[generate archive name using the current date]' \ @@ -126,7 +126,7 @@ case $service in '-w+[assign work directory]:work directory:_files -/' \ "$common[@]" \ '-z+[read archive comment from file]:comment file:_files' \ - '*:files:_files' && return + '*:files:_files' fi ;; esac diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf new file mode 100644 index 000000000..9312ea864 --- /dev/null +++ b/Completion/Unix/Command/_readelf @@ -0,0 +1,62 @@ +#compdef readelf eu-readelf + +local variant args sections + +_elf_file() { + [[ -x $REPLY || $REPLY = (core*|*.([ao]|so|elf)) ]] +} + +sections=( .bss .data .dynamic .dynsym .got .interp .shstrtab .symtab .text ) +_pick_variant -r variant elftoolchain=elftoolchain elfutils=elfutils binutils --version + +args=( + '(-a --all)'{-a,--all}'[show all tables]' + '(-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]' + '(-s --syms --symbols)'{-s,--syms,--symbols}'[show symbol table]' + '(-n --notes)'{-n,--notes}'[show core notes (if present)]' + '(-r --relocs)'{-r,--relocs}'[show relocations (if present)]' + '(-d --dynamic)'{-d,--dynamic}'[show dynamic section (if present)]' + '(-V --version-info)'{-V,--version-info}'[show version sections (if present)]' + '(-A --arch-specific)'{-A,--arch-specific}'[show architecture specific information (if any)]' + '(-c --archive-index)'{-c,--archive-index}'[show symbol/file index in an archive]' + \*{-x,--hex-dump=}"[dump contents of specified section as bytes]:section:($sections)" + \*{-p,--string-dump=}"[dump contents of specified section as strings]:section:($sections)" + '-w+[show the contents of DWARF2 debug sections]::debug section:(l L i a p r m f F s o R t)' + '--debug-dump=[show the contents of DWARF2 debug sections]::section:(rawline decodedline info abbrev pubnames aranges macro frames frames-interp str loc Ranges pubtypes gdb_index trace_info trace_abbrev trace_aranges)' + '(-I --histogram)'{-I,--histogram}'[show histogram of bucket list lengths]' + '(-W --wide)'{-W,--wide}'[allow output width to exceed 80 characters]' + '(- *)'{-H,--help}'[display help information]' + '(- *)'{-v,--version}'[display version information]' + "*:elf file:_files -g '*(-.e:_elf_file:)'" +) + +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]' + '(-u --unwind)'{-u,--unwind}'[show unwind info (if present)]' + '(-D --use-dynamic)'{-D,--use-dynamic}'[use dynamic section info when showing symbols]' + ) + ;| + binutils) + args+=( + '--dyn-syms[show dynamic symbol table]' + \*{-R,--relocated-dump=}"[dump contents of specified section as relocated bytes]:section:($sections)" + "--dwarf-depth=[don't show DIEs at greater than specified depth]:depth" + '--dwarf-start=[show DIEs starting at specified depth or deeper]:depth' + ) + ;; + elfutils) + args+=( + '--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]" + ) + ;; +esac + +_arguments -s "$args[@]" diff --git a/Completion/Unix/Command/_ri b/Completion/Unix/Command/_ri index feb10ec91..070f46ac2 100644 --- a/Completion/Unix/Command/_ri +++ b/Completion/Unix/Command/_ri @@ -3,7 +3,7 @@ local curcontext="$curcontext" state line ret=1 typeset -A opt_args -_arguments \ +_arguments -C \ '(- *)'{-h,--help}'[print help information and exit]' \ '(- *)'{-v,--version}'[display the version of ri]' \ '*'{-d,--doc-dir}'[directory to search for documentation]:ri doc directory:_files -/' \ @@ -42,8 +42,6 @@ if [[ "$state" = ri-name ]]; then if compset -P '?*(::|\#|.)'; then class_dir=${IPREFIX//(::|\#|.)/\/} - #else - # : fi esc_name=${${(Q)PREFIX}//(#b)([^A-Za-z0-9_])/$(printf %%%x ${(qq)match[1]})} diff --git a/Completion/Unix/Command/_rm b/Completion/Unix/Command/_rm index 1f156c481..4728ad464 100644 --- a/Completion/Unix/Command/_rm +++ b/Completion/Unix/Command/_rm @@ -1,4 +1,4 @@ -#compdef rm +#compdef rm grm zf_rm declare -a opts args args=( @@ -16,12 +16,25 @@ if _pick_variant gnu=gnu unix --help; then '--one-file-system[stay within filesystems of files given as arguments]' '( --preserve-root)--no-preserve-root[do not treat / specially]' '(--no-preserve-root )--preserve-root[do not remove / (default)]' + '(-d --dir)'{-d,--dir}'[remove directories as well]' '(-v --verbose)'{-v,--verbose}'[explain what is being done]' '(- *)--help[display help message and exit]' '(- *)--version[output version information and exit]' ) else args=(${args:#*--(force|recursive)\[*}) + case $OSTYPE in + freebsd*) + args+=( + '-d[remove directories as well]' + '(-i)-I[prompt when removing many files]' + '-P[overwrite files before deleting them]' + '-v[explain what is being done]' + '-W[attempt to undelete named files]' + "-x[don't cross file systems when removing a hierarchy]" + ) + ;; + esac fi local curcontext=$curcontext state line ret=1 diff --git a/Completion/Unix/Command/_rsync b/Completion/Unix/Command/_rsync index 7bad03a05..79d8243e1 100644 --- a/Completion/Unix/Command/_rsync +++ b/Completion/Unix/Command/_rsync @@ -35,10 +35,10 @@ if compset -P '*::*/' || compset -P 'rsync://*/*/'; then # attrs size date time name _wanted files expl 'remote file or directory' \ - compadd -d remdispf ${${${${remdispf##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##} + compadd -d remdispf ${${${${remdispf##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##} && ret=0 _wanted files expl 'remote file or directory' \ - compadd -S/ -d remdispd ${${${${remdispd##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##} + compadd -S/ -d remdispd ${${${${remdispd##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##} || (( ! ret )) elif compset -P 1 '*::' || compset -P 1 'rsync://*/'; then diff --git a/Completion/Unix/Command/_rubber b/Completion/Unix/Command/_rubber index 09e289aa2..f66540a9f 100644 --- a/Completion/Unix/Command/_rubber +++ b/Completion/Unix/Command/_rubber @@ -15,24 +15,24 @@ else fi _rubber_args=( - \*{-c,--command}'=[run the directive CMD before parsing]:command' - \*{-e,--epilogue}'=[run the directive CMD after parsing]:command' - {-z,--gzip}'[compress the final document]' - '(- *)'{-h,--help}'[show help]' - '--into=[go to directory DIR before compiling]:directory:_files -/' - {-l,--landscape}'[change paper orientation (if relevant)]' - {-n,--maxerr}'=[display at most NUM errors]:num' - \*{-m,--module}'=[use module]:module:($_rubber_modules)' - '--only=[only include the specified SOURCES]:sources' - \*{-o,--post}'=[postprocess with module]:postprocessor:($_rubber_modules)' - {-d,--pdf}'[produce PDF output instead of DVI]' - {-p,--ps}'[produce a PostScript document]' - {-q,--quiet}'[suppress messages]' - \*{-r,--read}'[read additional directives from a file]:directives files:_files' - {-s,--short}'[display errors in a compact form]' - \*{-I,--texpath}'=[add DIR to the search path for LaTeX]:tex path:_files -/' - \*{-v,--verbose}'[increase verbosity]' - '--version[print version information and exit]' + \*{-c,--command}'=[run specified directive command before parsing]:command' + \*{-e,--epilogue}'=[run specified directive command after parsing]:command' + '(-z --gzip)'{-z,--gzip}'[compress the final document]' + '(- *)'{-h,--help}'[show help information]' + '--into=[go to specified directory before compiling]:directory:_files -/' + '(-l --landscape)'{-l,--landscape}'[change paper orientation (if relevant)]' + '(-n --maxerr)'{-n,--maxerr}'=[display at most specified number of errors]:number' + \*{-m,--module}'=[use module]:module:($_rubber_modules)' + '--only=[only include the specified sources]:sources' + \*{-o,--post}'=[postprocess with module]:postprocessor:($_rubber_modules)' + '(-d --pdf -p -ps)'{-d,--pdf}'[produce PDF output instead of DVI]' + '(-p -ps -d --pdf)'{-p,--ps}'[produce a PostScript document]' + {-q,--quiet}'[suppress messages]' + \*{-r,--read}'[read additional directives from a file]:directives files:_files' + {-s,--short}'[display errors in compact form]' + \*{-I,--texpath}'=[add directory to the search path for LaTeX]:tex path:_files -/' + \*{-v,--verbose}'[increase verbosity]' + '--version[print version information and exit]' ) case "$service" in @@ -42,17 +42,15 @@ case "$service" in '--clean[remove produced files instead of compiling]' \ {-f,--force}'[force at least one compilation]' \ '--inplace[compile the documents from their source directory]' \ - \*{-W,--warn}'=[report warnings of the given TYPE]:warnings:(all boxes misc refs)' \ + \*{-W,--warn}'=[report warnings of the given type]:warnings:(all boxes misc refs)' \ '*:LaTeX files:_files -g "*.(tex|dtx|lhs|w)(-.)"' - return 0 ;; rubber-pipe) _arguments -s \ "$_rubber_args[@]" \ {-k,--keep}'[keep the temporary files after compiling]' \ - \*{-W,--warn}'=[report warnings of the given TYPE]:warnings:(all boxes misc refs)' - return 0 + \*{-W,--warn}'=[report warnings of the given type]:warnings:(all boxes misc refs)' ;; rubber-info) @@ -65,8 +63,5 @@ case "$service" in '--refs[show the list of undefined references]' \ '--warnings[show all LaTeX warnings]' \ ':LaTeX file:_files -g "*.(tex|dtx|lhs|w)(-.)"' - return 0 ;; esac - -return 1 diff --git a/Completion/Unix/Command/_ruby b/Completion/Unix/Command/_ruby index 946ebe270..49a1170ef 100644 --- a/Completion/Unix/Command/_ruby +++ b/Completion/Unix/Command/_ruby @@ -95,7 +95,7 @@ case "$service" in _arguments -C -s : $irb $all $common && ret=0 ;; erb[0-9.]#) - RUBY=${words[1]/irb/ruby} + RUBY=${words[1]/erb/ruby} _arguments -C -s : $erb $all \ '*:erb file:_files -g "*.erb(-.)"' && ret=0 ;; diff --git a/Completion/Unix/Command/_runit b/Completion/Unix/Command/_runit new file mode 100644 index 000000000..81ba26a44 --- /dev/null +++ b/Completion/Unix/Command/_runit @@ -0,0 +1,73 @@ +#compdef sv + +_sv_commands() { + local -a sv_ary + sv_ary=( + 'status':'get status of service (and log service if available)' + 'up':'start if service is running. If service stops, restart' + 'down':'send SIGTERM and SIGCONT if service is running. After it stops, do not restart' + 'once':'start if service is not running. Do not restart if it stops' + 'pause':'send SIGSTOP if service is running' + 'cont':'send SIGCONT if service is running' + 'hup':'send SIGHUP if service is running' + 'alarm':'send SIGALRM if service is running' + 'interrupt':'send SIGINT if service is running' + 'quit':'send SIGQUIT if service is running' + '1':'send SIGUSR1 if service is running' + '2':'send SIGUSR2 if service is running' + 'term':'send SIGTERM if service is running' + 'kill':'send SIGKILL if service is running' + 'exit':'send SIGTERM and SIGCONT if service is running. Do not restart service.' + ) + _describe -t commands "sv commands" sv_ary -V sv_commands +} + +_sv_lsb() { + local -a sv_lsb_ary + sv_lsb_ary=( + 'start':'up with check/timeout' + 'stop':'down with check/timeout' + 'reload':'hup with check' + 'restart':'down and up with check' + 'shutdown':'exit with check/timeout' + 'force-stop':'stop with kill on timeout' + 'force-reload':'reload with kill on timeout' + 'force-restart':'restart with kill on timeout' + 'force-shutdown':'shutdown with kill on timeout' + 'try-restart':'restart if service is already running' + ) + + _describe -t lsb-commands "sv LSM init compat" sv_lsb_ary -V sv_init_compat +} + +_sv_additional() { + _describe -t additional-commands "sv additional commands" '("check:check status of service")' -V sv_addl_comm +} + +local curcontext="$curcontext" state line +_arguments -C \ + '-v[verbose]' \ + '-w[wait time]:time (seconds)' \ + '1: :->command' \ + '*:: :->options' + +case $state in + (command) + _alternative \ + _sv_commands \ + _sv_lsb \ + _sv_additional + ;; + + (options) + local -a sv_services + local svdir=${SVDIR:-/etc/service} + sv_services=( + $svdir/*(N) + $svdir/*/log(N) + ) + + sv_services=( ${sv_services#$svdir/} ) + _describe -t services "sv services" sv_services + ;; +esac diff --git a/Completion/Unix/Command/_sablotron b/Completion/Unix/Command/_sablotron index 170f08abd..53e0bec92 100644 --- a/Completion/Unix/Command/_sablotron +++ b/Completion/Unix/Command/_sablotron @@ -20,15 +20,8 @@ _arguments -C \ if [[ -n "$state" ]]; then mode="${opt_args[(i)-c|--chain-xsl]:+chain}${opt_args[(i)-x|--batch-xml]:+batch-x}${opt_args[(i)-s|--batch-xsl]:+batch-s}" [[ $mode = (chain|batch-[xs]) ]] || mode=default - _tags assignments files + _tags files assignments while _tags; do - if _requested assignments; then - if [[ -prefix *= ]]; then - _message -e value value - else - _message -e parameter 'parameter name' - fi - fi if _requested files; then case $mode:${#words[1,CURRENT-1]:#(-*|*=*)}; in default:1|chain:<3->|batch-x:2|batch-s:1) @@ -45,6 +38,13 @@ if [[ -n "$state" ]]; then ;; esac fi + if _requested assignments; then + if [[ -prefix *= ]]; then + _message -e value value + else + _message -e parameter 'parameter name' && ret=0 + fi + fi (( ret )) || break done fi diff --git a/Completion/Unix/Command/_screen b/Completion/Unix/Command/_screen index 931946c78..510fd7195 100644 --- a/Completion/Unix/Command/_screen +++ b/Completion/Unix/Command/_screen @@ -1,20 +1,8 @@ #compdef screen -local curcontext="$curcontext" state line expl +local curcontext="$curcontext" state line expl ret=1 local scr_cmds sessions -function __screen_normal() { - if (( CURRENT == 1 )) && [[ $PREFIX == /dev/* ]]; then - _path_files -g '*(%)' - elif (( CURRENT == 2 )) && [[ ${words[1]} == /dev/* ]]; then - _message "baud rate" - elif (( CURRENT > 2 )) && [[ ${words[1]} == /dev/* ]]; then - _message "no more parameters" - else - _normal "$@" - fi -} - scr_cmds=( acladd aclchg acldel aclgrp aclumask activity addacl allpartial @@ -103,10 +91,21 @@ _arguments -C \ '-Dx: :->any-sessions' \ '-dx: :->any-sessions' \ '-X[execute command as a screen command in the specified session]:screencmd:(${scr_cmds[@]})' \ - '*::arguments: __screen_normal' + '*:: :->normal' && ret=0 if [[ -n $state ]]; then case $state in + normal) + if (( CURRENT == 1 )) && [[ $PREFIX == /dev/* ]]; then + _path_files -g '*(%)' + elif (( CURRENT == 2 )) && [[ ${words[1]} == /dev/* ]]; then + _message "baud rate" + elif (( CURRENT > 2 )) && [[ ${words[1]} == /dev/* ]]; then + _message "no more parameters" + else + _normal + fi + ;; attached-sessions) sessions=( ${${${(M)${(f)"$(_call_program screen-sessions $words[1] \ @@ -134,4 +133,6 @@ if [[ -n $state ]]; then _wanted screen-sessions expl "${state%-*} screen process" \ compadd ${sessions#*.} fi -fi +fi && ret=0 + +return ret diff --git a/Completion/Unix/Command/_sed b/Completion/Unix/Command/_sed index 476575205..8e2385cc8 100644 --- a/Completion/Unix/Command/_sed +++ b/Completion/Unix/Command/_sed @@ -1,22 +1,29 @@ -#compdef sed +#compdef sed gsed psed s2p -local args +local args inplace extended args=( '(-n --quiet --silent)'{-n,--quiet,--silent}'[suppress automatic printing of pattern space]' - '(1)*'{-e,--expression=-}'[add sed commands to run]:sed script' + '(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' '*:input file:_files' ) +inplace='[edit files in-place, running scripts separately for each file]::suffix for backup' +extended='[use extended regular expressions]' -if _pick_variant gnu=GNU unix --version; then +if [[ $service = (psed|s2p) ]]; then + args=( + "${(@)args:#(|\(*\))(|\*)--*}" + '-a[delay opening files listed with w function]' + ) +elif _pick_variant gnu=GNU unix --version; then args+=( '--follow-symlinks[follow symlinks when processing in place]' - '(-i --in-place)'{-i-,--in-place=-}'[edit files in place]::suffix for backup' + '(-i --in-place)'{-i-,--in-place=-}$inplace '(-l --line-length)'{-l,--line-length=-}'[specify line-wrap length for the l command]' '(-r)--posix[disable GNU extensions]' - '(-r --regexp-extended)'{-r,--regexp-extended}'[use extended regular expressions]' + '(-r --regexp-extended)'{-r,--regexp-extended}$extended '(-s --separate)'{-s,--separate}'[consider files separately instead of as a combined stream]' '(-u --unbuffered)'{-u,--unbuffered}'[disable data buffering]' '(- 1 :)--help[print program usage]' @@ -24,6 +31,27 @@ if _pick_variant gnu=GNU unix --version; then ) else args=( "${(@)args:#(|\(*\))(|\*)--*}" ) + case $OSTYPE in + openbsd*|freebsd*|netbsd*|darwin*|dragonfly*) + args+=( + '(-r -E)'{-r,-E}$extended + '-a[delay opening files listed with w function]' + ) + ;| + darwin*|freebsd*|netbsd*) + args+=( + '-i'$inplace + '-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' + ) + ;; + openbsd*) args+=( '-u[make output line buffered]' ) ;; + esac fi -_arguments "$args[@]" +_arguments -s "$args[@]" diff --git a/Completion/Unix/Command/_sh b/Completion/Unix/Command/_sh index 104c7576c..21ebfc3b2 100644 --- a/Completion/Unix/Command/_sh +++ b/Completion/Unix/Command/_sh @@ -10,8 +10,7 @@ if [[ $service == zsh ]]; then fi if (( CURRENT == ${words[(i)-c]} + 1 )); then - compset -q - _normal + _cmdstring else local n=${words[(b:2:i)[^-]*]} if (( n <= CURRENT )); then diff --git a/Completion/Unix/Command/_sort b/Completion/Unix/Command/_sort index ff36b9b3d..2e7f0a01a 100644 --- a/Completion/Unix/Command/_sort +++ b/Completion/Unix/Command/_sort @@ -1,37 +1,76 @@ -#compdef sort +#compdef sort gsort +local args variant local ordering='(-d --dictionary-order -g --general-numeric-sort -M --month-sort -h --human-numeric-sort -n --numeric-sort --sort -V --version-sort --help --version)' -_arguments -s -S \ - '(-b --ignore-leading-blanks)'{-b,--ignore-leading-blanks}'[ignore leading blanks]' \ - "$ordering"{-d,--dictionary-order}'[consider only blanks and alphanumeric characters]' \ - '(-f --ignore-case)'{-f,--ignore-case}'[fold lower case to upper case characters]' \ - "$ordering"{-g,--general-numeric-sort}'[compare according to general numeric value]' \ - '(-i --ignore-nonprinting)'{-i,--ignore-nonprinting}'[consider only printable characters]' \ - "$ordering"{-M,--month-sort}"[compare (unknown) < 'JAN' < ... < 'DEC']" \ - "$ordering"{-h,--human-numeric-sort}'[compare human readable numbers (e.g., 2K 1G)]' \ - "$ordering"{-n,--numeric-sort}'[compare according to string numerical value]' \ - "$ordering"{-R,--random-sort}'[sort by random hash of keys]' \ - '--random-source=[get random bytes from file]:file:_files' \ - '(-r --reverse)'{-r,--reverse}'[reverse the result of comparisons]' \ - "$ordering--sort=[sort according to ordering]:ordering:(general-numeric human-numeric month numeric random version)" \ - "$ordering"{-V,--version-sort}'[sort version numbers]' \ - '--batch-size=[maximum inputs to merge]:number' \ - '(-c --check -C)'{-c,-C}'[check whether input is sorted; do not sort]' \ - '(-c --check -C)--check=-[check whether input is sorted; do not sort]::bad line handling:(diagnose-first silent quiet)' \ - '--compress-program=[specify program to compress temporary files with]:program:(gzip bzip2 lzop xz)' \ - '--debug[annotate the of the line used to sort]' \ - '--files0-from=[read input files from file]:file:_files' \ - '(-k --key)'{-k+,--key=}'[start a key at POS1, end it as POS2 (origin 1)]:key' \ - '(-m --merge)'{-m,--merge}'[merge already sorted files; do not sort]' \ - '(-o --output)'{-o+,--output=}'[write result to file instead of standard output]:output file:_files' \ - '(-s --stable)'{-s,--stable}'[preserve original order of lines with the same key]' \ - '(-S --buffer-size)'{-S+,--buffer-size=}'[specify size for main memory buffer]:size' \ - '(-t --field-separator)'{-t+,--field-separator=}'[specify field separator instead of non-blank to blank transition]:separator' \ - \*{-T+,--temporary-directory=}'[specify directory for temporary files]:directory:_directories' \ - '(-u --unique)'{-u,--unique}'[with -c, check for strict ordering; without -c, output only the first of an equal run]' \ - '--parallel=[set number of sorts run concurrently]:number' \ - '(-z --zero-terminated)'{-z,--zero-terminated}'[end lines with 0 byte, not newline]' \ - '(- *)--help[display help and exit]' \ - '(- *)--version[output version information and exit]' \ - '*:file:_files' +args=( + '(-c --check -C)-c[check whether input is sorted; do not sort]' + '(-m --merge)'{-m,--merge}'[merge already sorted files; do not sort]' + '(-o --output)'{-o+,--output=}'[write result to file instead of standard output]:output file:_files' + \*{-T+,--temporary-directory=}'[specify directory for temporary files]:directory:_directories' + '(-u --unique)'{-u,--unique}'[with -c, check for strict ordering; without -c, output only the first of an equal run]' + "$ordering"{-d,--dictionary-order}'[consider only blanks and alphanumeric characters]' + '(-f --ignore-case)'{-f,--ignore-case}'[fold lower case to upper case characters]' + '(-i --ignore-nonprinting)'{-i,--ignore-nonprinting}'[consider only printable characters]' + "$ordering"{-n,--numeric-sort}'[compare according to string numerical value]' + '(-r --reverse)'{-r,--reverse}'[reverse the result of comparisons]' + '(-b --ignore-leading-blanks)'{-b,--ignore-leading-blanks}'[ignore leading blanks]' + '(-t --field-separator)'{-t+,--field-separator=}'[specify field separator instead of non-blank to blank transition]:separator' + '(-k --key)'{-k+,--key=}'[specified start and end fields for key]:key field' +) + +_pick_variant -r variant gnu=GNU $OSTYPE --version +case $variant in + dragonfly*|netbsd*|openbsd*|freebsd*|gnu) + args+=( + '(-s --stable)'{-s,--stable}'[preserve original order of lines with the same key]' + ) + ;| + openbsd*|freebsd*|gnu) + args+=( + '(-c --check -C)-C[check whether input is sorted; do not sort]' + '(-z --zero-terminated)'{-z,--zero-terminated}'[end lines with 0 byte, not newline]' + ) + ;| + freebsd*|gnu) + args+=( + '(-c --check -C)--check=-[check whether input is sorted; do not sort]::bad line handling:(diagnose-first silent quiet)' + "$ordering"{-g,--general-numeric-sort}'[compare according to general numeric value]' + "$ordering"{-M,--month-sort}"[compare (unknown) < 'JAN' < ... < 'DEC']" + "$ordering"{-h,--human-numeric-sort}'[compare human readable numbers (e.g., 2K 1G)]' + "$ordering"{-R,--random-sort}'[sort by random hash of keys]' + "$ordering"{-V,--version-sort}'[sort version numbers]' + "$ordering--sort=[sort according to ordering]:ordering:(general-numeric human-numeric month numeric random version)" + '(-i --ignore-nonprinting)'{-i,--ignore-nonprinting}'[consider only printable characters]' + '--random-source=[get random bytes from file]:file:_files' + '--batch-size=[maximum inputs to merge]:number' + '--compress-program=[specify program to compress temporary files with]:program:(gzip bzip2 lzop xz)' + '--debug[annotate the of the line used to sort]' + '--files0-from=[read input files from file]:file:_files' + '(-S --buffer-size)'{-S+,--buffer-size=}'[specify size for main memory buffer]:size' + '(- *)--help[display help and exit]' + '(- *)--version[output version information and exit]' + ) + ;| + netbsd*|dragonfly*) + args+=( + "${ordering}-l[sort by string length of field]" + "(-s)-S[don't use stable sort" + ) + ;| + openbsd*) + args+=( + '-H[use a merge sort instead of a radix sort]' + '-R[specify record separator]:separator' + ) + ;| + gnu) + args+=( '--parallel=[set number of sorts run concurrently]:number' ) + ;; + freebsd*) + args+=( --radixsort --mergesort --qsort --heapsort --mmap ) + ;; + *) args=( "${(@)args:#(|\(*\))(|\*)--*}" ) ;; +esac + +_arguments -s -S $args '*:file:_files' diff --git a/Completion/Unix/Command/_stgit b/Completion/Unix/Command/_stgit index 6248267eb..f313f651a 100644 --- a/Completion/Unix/Command/_stgit +++ b/Completion/Unix/Command/_stgit @@ -40,11 +40,11 @@ else compadd ${${(M)${(f)"$(stg series 2> /dev/null)"}##[+>] *}#[+>] } \ && ret=0 else - _files + _files && ret=0 fi ;; (*) - _files + _files && ret=0 ;; esac fi diff --git a/Completion/Unix/Command/_strip b/Completion/Unix/Command/_strip index 06f7243b5..726d87c2b 100644 --- a/Completion/Unix/Command/_strip +++ b/Completion/Unix/Command/_strip @@ -1,6 +1,6 @@ #compdef strip -local curcontext=$curcontext state line ret=0 +local curcontext=$curcontext state line ret=1 declare -A opt_args declare -a args @@ -11,8 +11,8 @@ if _pick_variant gnu=GNU solaris --version; then local expl _description files expl 'command-line-options file' - _files $expl && ret=0 - return $ret + _files "$expl[@]" + return fi args=( '(-F --target)'{-F+,--target=}'[object code format to use]:bfd name:->bfdnames' @@ -52,9 +52,9 @@ case $state in local expl declare -a bfdnames - bfdnames=(${=${(M)${(f)"$(_call_program bfdnames strip --help 2>/dev/null)"}:#strip: supported targets: *}#strip: supported targets: }) + bfdnames=(${=${(M)${(f)"$(_call_program bfdnames strip --help)"}:#strip: supported targets: *}#strip: supported targets: }) _describe -t bfdnames 'bfd name' bfdnames && ret=0 ;; esac -return $ret +return ret diff --git a/Completion/Unix/Command/_su b/Completion/Unix/Command/_su index 6d0f2cd9f..057a41371 100644 --- a/Completion/Unix/Command/_su +++ b/Completion/Unix/Command/_su @@ -1,9 +1,9 @@ #compdef su local -A opt_args -local -a args state context +local -a args context state line expl local shell=${words[(i)(-s|--shell=*)]} first='1:user name:_users' -local usr=root line +local usr=root if _pick_variant gnu="Free Software Foundation" unix --version; then args=( @@ -20,10 +20,21 @@ if _pick_variant gnu="Free Software Foundation" unix --version; then ) else args=( - '-c[pass command to shell]:command string:->command' '-l[use a login shell]' '-s[run the specified shell]:shell:->shell' ) + case $OSTYPE in + freebsd*) + args=( + '-c[use settings from specified login class]:class' + '-f[if the invoked shell is csh, prevent it from reading .cshrc]' + '-l[use a login shell]' + '-m[do not reset environment]' + '-s[set the MAC label]' + ) + ;; + *) args+=( '-c[pass command to shell]:command string:->command' ) ;; + esac fi if [[ $#words -ge 2 && $words[2] != -* && CURRENT -ne 2 ]]; then @@ -50,11 +61,11 @@ case $state in return ;; (shell) - compadd ${(f)^"$(</etc/shells)"}(N) + _wanted -C $context shells expl shell compadd ${(f)^"$(</etc/shells)"}(N) return ;; (rest) - if [[ -z $shell || $shell = */nologin ]]; then + if [[ -z $shell || $shell = */(nologin|false) ]]; then _arguments "-s[run the specified shell, $usr has no shell]" || _message "-s option required, $usr has no shell" compstate[insert]= diff --git a/Completion/Unix/Command/_sudo b/Completion/Unix/Command/_sudo index f8543f865..63ac37f62 100644 --- a/Completion/Unix/Command/_sudo +++ b/Completion/Unix/Command/_sudo @@ -1,6 +1,8 @@ #compdef sudo sudoedit -local curcontext="$curcontext" environ e +setopt localoptions extended_glob + +local environ e local -a args zstyle -a ":completion:${curcontext}:" environ environ @@ -10,33 +12,44 @@ do local -x "$e" done args=( - '-V[show version]' - '-l[list allowed commands]' - '-L[list options from Default section]' - '-a[BSD auth type]:BSD auth type:' - '-c[BSD login class]:BSD login class:' - '-h[show help]' - '-v[validate user timestamp]' - '-k[invalidate user timestamp]' - '-K[remove user timestamp]' - '-r[Kerberos realm]:Kerberos realm:' - '-p[password prompt]:password prompt:' - '-u[user name]:user name:_users' - '-S[read password from stdin]' + '(-A --askpass)'{-A,--askpass}'[use a helper program for password prompting]' + '(-C --close-from)'{-C+,--close-from=}'[close file descriptors]:lowest fd to close' + '(-g --group)'{-g+,--group=}'[run command as the specified group name or ID]:group:_groups' + '(-)'{-h,--help}'[display help message and exit]' + '(-h --host)'{-h+,--host=}'[run command on host]:host:_hosts' + '(-K --remove-timestamp)'{-K,--remove-timestamp}'[remove timestamp file completely]' + '(-k --reset-timestamp)'{-k,--reset-timestamp}'[invalidate timestamp file]' + \*{-l,--list}"[list user's privileges or check a specific command]" + '(-n --non-interactive)'{-n,--non-interactive}'[non-interactive mode, no prompts are used]' + '(-p --prompt)'{-p+,--prompt=}'[use the specified password prompt]:prompt' + '(-r --role)'{-r+,--role=}'[create SELinux security context with specified role]:role' + '(-S --stdin)'{-S,--stdin}'[read password from standard input]' + '(-t --type)'{-t+,--type=}'[create SELinux security context with specified type]:type' + '(-U --other-user)'{-U+,--other-user=}'[in list mode, display privileges for user]:user:_users' + '(-u --user)'{-u+,--user=}'[run command (or edit file) as specified user]:user:_users' + '(-)'{-V,--version}'[display version information and exit]' + '(-v --validate)'{-v,--validate}"[update user's timestamp without running a command]" ) -if [[ $service = sudoedit ]]; then - _arguments $args \ - '*:file: _files' +# Does -e appears before the first word that doesn't begin with a hyphen? +# The way (i) works in subscripts, the test will always be true if all the +# words begin with a hyphen. +# +# TODO: use _arguments' $opt_args to detect the cases '-u jrandom -e' and '-Ae' +if [[ $service = sudoedit ]] || (( $words[(i)-e] < $words[(i)^(*sudo|-[^-]*)] )) ; then + args=( -A "-*" $args '!(-V --version -h --help)-e' '*:file:_files' ) else - _arguments $args \ - '(- :)-e[edit file]:*:file:_files' \ - '(- :)-s[run SHELL]' \ - '(- :)-i[simulate login]' \ - '(-i -s -e)-b[run command in background]' \ - '(-i -s -e)-E[preserve environment]' \ - '(-i -s -e)-H[set HOME environment variable]' \ - '(-i -s -e)-P[preserve group vector]' \ - '(-):command: _command_names -e' \ + args+=( + '(-e --edit 1 *)'{-e,--edit}'[edit files instead of running a command]' \ + '(-s --shell)'{-s,--shell}'[run shell as the target user; a command may also be specified]' \ + '(-i --login)'{-i,--login}'[run login shell as the target user; a command may also be specified]' \ + '(-b --background -i --login -s --shell -e --edit)'{-b,--background}'[run command in the background]' \ + '(-E --preserve-env -i --login -s --shell -e --edit)'{-E,--preserve-env}'[preserve user environment when running command]' \ + '(-H --set-home -i --login -s --shell -e --edit)'{-H,--set-home}"[set HOME variable to target user's home dir]" \ + '(-P --preserve-groups -i -login -s --shell -e --edit)'{-P,--preserve-groups}"[preserve group vector instead of setting to target's]" \ + '(-)1:command: _command_names -e' '*::arguments: _normal' + ) fi + +_arguments -s -S $args diff --git a/Completion/Unix/Command/_systemd b/Completion/Unix/Command/_systemd index d2a7895e1..028ecddd9 100644 --- a/Completion/Unix/Command/_systemd +++ b/Completion/Unix/Command/_systemd @@ -132,9 +132,9 @@ _hosts_or_user_at_host() ) if (( CURRENT == 1 )); then - _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@" + _describe -t commands 'systemctl command' _systemctl_cmds else - local curcontext="$curcontext" + local curcontext="$curcontext" ret cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}" # Deal with any aliases diff --git a/Completion/Unix/Command/_telnet b/Completion/Unix/Command/_telnet index c7ab34f98..1674eedd8 100644 --- a/Completion/Unix/Command/_telnet +++ b/Completion/Unix/Command/_telnet @@ -12,8 +12,8 @@ if (( ! $+_telnet_args )); then local help="$(_call_program options 'telnet -\?' < /dev/null 2>&1)" local -A optionmap optionmap=( - '*\[-4\]*' '-4[Force IPv4 address resolution]' - '*\[-6\]*' '-6[Force IPv6 address resolution]' + '*\[-4\]*' '-4[force IPv4 address resolution]' + '*\[-6\]*' '-6[force IPv6 address resolution]' '*\[-8\]*' '-8[allow 8-Bit data]' '*\[-E\]*' '-E[disable an escape character]' '*\[-K\]*' '-K[no automatic login]' @@ -52,16 +52,16 @@ _arguments -C -s \ case "$state" in ssl) _values -w 'SSL parameter' \ - 'debug[Send SSL debugging info to stderr]' \ - '(nossl)ssl[Negotiate SSL connection]' \ - '(ssl)nossl[Switch off SSL negotiation]' \ - 'certrequired[Require server certificate]' \ - 'secure[No fallback to unencrypted mode]' \ - 'verbose[Be verbose about certificates, etc.]' \ - 'verify[Set SSL verify flags]:int:' \ - 'cert[Specify certificate file]:certificate file:_path_files' \ - 'key[Specify key file]:key file:_path_files' \ - 'cipher[Set preferred cipher list]:ciphers:' + 'debug[send SSL debugging info to stderr]' \ + '(nossl)ssl[negotiate SSL connection]' \ + '(ssl)nossl[switch off SSL negotiation]' \ + 'certrequired[require server certificate]' \ + 'secure[no fallback to unencrypted mode]' \ + 'verbose[be verbose about certificates, etc.]' \ + 'verify[set SSL verify flags]:int' \ + 'cert[specify certificate file]:certificate file:_path_files' \ + 'key[specify key file]:key file:_path_files' \ + 'cipher[set preferred cipher list]:cipher' && ret=0 ;; hosts) diff --git a/Completion/Unix/Command/_tidy b/Completion/Unix/Command/_tidy index fce719026..ec2d74238 100644 --- a/Completion/Unix/Command/_tidy +++ b/Completion/Unix/Command/_tidy @@ -123,6 +123,4 @@ _arguments \ '--css-prefix:CSS class name:' \ '--accessibility-check:priority level:(${access[@]})' \ '--newline:newline character:(LF CRLF CR)' \ - '*:file:_files' && return - -return 1 + '*:file:_files' diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux index 5a4a2d71f..f0cc4be37 100644 --- a/Completion/Unix/Command/_tmux +++ b/Completion/Unix/Command/_tmux @@ -1490,7 +1490,7 @@ function __tmux-windows() { # And here is the actual _tmux(), that puts it all together: function _tmux() { local curcontext="${curcontext}" - local mode state ret + local mode state ret=1 local -a args local -x tmuxcommand unset tmux_describe @@ -1508,22 +1508,22 @@ function _tmux() { '-v[request verbose logging]' '*:: :->subcommand_or_options' ) - _arguments -C -s -w ${args} && return + _arguments -C -s -w ${args} && ret=0 if [[ ${state} == "subcommand_or_options" ]]; then if (( CURRENT == 1 )) ; then zstyle -s ":completion:${curcontext}:subcommands" mode mode || mode='both' if [[ ${mode} == 'commands' ]]; then - _describe -t subcommands 'tmux commands' _tmux_commands + _describe -t subcommands 'tmux commands' _tmux_commands && ret=0 elif [[ ${mode} == 'aliases' ]]; then - _describe -t subcommands 'tmux aliases' _tmux_aliases + _describe -t subcommands 'tmux aliases' _tmux_aliases && ret=0 else - _describe -t subcommands 'tmux commands and aliases' _tmux_commands -- _tmux_aliases + _describe -t subcommands 'tmux commands and aliases' _tmux_commands -- _tmux_aliases && ret=0 fi else if (( ${+commands[tmux]} == 0 )); then _message '`tmux'\'' not found in $path; sub-cmd completions disabled.' - return 0 + return fi tmuxcommand="${words[1]}" if [[ -n ${_tmux_aliasmap[$tmuxcommand]} ]] ; then @@ -1545,6 +1545,7 @@ function _tmux() { _call_function ret _tmux-${tmuxcommand} fi fi + return ret } # description generation follows; only done on 1st _tmux call. diff --git a/Completion/Unix/Command/_uname b/Completion/Unix/Command/_uname index 9b4663b8a..414a82a87 100644 --- a/Completion/Unix/Command/_uname +++ b/Completion/Unix/Command/_uname @@ -1,53 +1,81 @@ #compdef uname typeset -A _uname_args +local -a args + +case $LANG in + de_*) + _uname_args=( + all "alle Grundinformationen ausgeben" + kernel-name "Namen des Kernels ausgeben" + nodename "Netzwerknamen der Maschine ausgeben" + kernel-release "Release-Nummer des Kernels ausgeben" + kernel-version "Version des Kernels ausgeben" + os-release "Release-Nummer des Betriebssystems ausgeben" + machine "Maschinentyp (Hardware) ausgeben" + processor "Typ des Prozessors ausgeben" + hardware-platform "Hardwareplattform ausgeben" + operating-system "Namen des Betriebssystems ausgeben" + help "Hilfe anzeigen und beenden" + version "Versionsinformation anzeigen und beenden" + ) + ;; + (*) + _uname_args=( + all "print all basic information" + kernel-name "print kernel name" + nodename "print network node hostname" + kernel-release "print kernel release" + kernel-version "print kernel version" + os-release "print operating system release level" + machine "print machine hardware name" + processor "print processor type" + hardware-platform "print hardware platform" + operating-system "print name of the operating system" + help "display help information" + version "output version information and exit" + ) + ;; +esac if _pick_variant gnu="Free Soft" unix --version; then - case $LANG in - (de_DE.UTF-8) - _uname_args=( - all "alle Informationen ausgeben" - kernel-name "Namen des Kernels ausgeben" - nodename "Netzwerknamen der Maschine ausgeben" - kernel-release "Release-Nummer des Kernels ausgeben" - kernel-version "Version des Kernels ausgeben" - machine "Maschinentyp (Hardware) ausgeben" - processor "Typ des Prozessors ausgeben (oder das Wort unknown)" - hardware-platform "Hardwareplattform ausgeben (oder das Wort unknown)" - operating-system "Namen des Betriebssystems ausgeben" - help "diese Hilfe anzeigen und beenden" - version "Versionsinformation anzeigen und beenden" - ) + _arguments -s \ + '(-)'{--all,-a}'['$_uname_args[all]']' \ + '(--kernel-name -s)'{--kernel-name,-s}'['$_uname_args[kernel-name]']' \ + '(--nodename -n)'{--nodename,-n}'['$_uname_args[nodename]']' \ + '(--kernel-release -r)'{--kernel-release,-r}'['$_uname_args[kernel-release]']' \ + '(--kernel-version -v)'{--kernel-version,-v}'['$_uname_args[kernel-version]']' \ + '(--machine -m)'{--machine,-m}'['$_uname_args[machine]']' \ + '(--processor -p)'{--processor,-p}'['$_uname_args[processor]']' \ + '(--hardware-platform -i)'{--hardware-platform,-i}'['$_uname_args[hardware-platform]']' \ + '(--operating-system -o)'{--operating-system,-o}'['$_uname_args[operating-system]']' \ + '(-)--help['$_uname_args[help]']' \ + '(-)--version['$_uname_args[version]']' +else + args=( + "(-m -n -r -s -v)-a[${_uname_args[all]}]" + '-m[print hardware class]' + "-n[${_uname_args[nodename]}]" + "-p[${_uname_args[processor]}]" + "-r[${_uname_args[os-release]}]" + "-s[${_uname_args[operating-system]}]" + '-v[print detailed operating system version]' + ) + case $OSTYPE in + freebsd*|dragonfly*) args+=( '-i[print kernel ident]' ) ;| + freebsd<10->.*) + args+=( + '-K[print FreeBSD kernel version]' + '-U[print FreeBSD user environment version]' + ) ;; - (*) - _uname_args=( - all "print all information" - kernel-name "print the kernel name" - nodename "print the network node hostname" - kernel-release "print the kernel release" - kernel-version "print the kernel version" - machine "print the machine hardware name" - processor "print the processor type or \"unknown\"" - hardware-platform "print the hardware platform or \"unknown\"" - operating-system "print the operating system" - help "display this help and exit" - version "output version information and exit" - ) + solaris*) + args+=( + '-i[print platform name]' + '-S[set system name]:system name' + '-X[print expanded system information]' + ) ;; esac - - _arguments \ - '(--all -a)'{--all,-a}'['$_uname_args[all]']' \ - '(--kernel-name -s)'{--kernel-name,-s}'['$_uname_args[kernel-name]']' \ - '(--nodename -n)'{--nodename,-n}'['$_uname_args[nodename]']' \ - '(--kernel-release -r)'{--kernel-release,-r}'['$_uname_args[kernel-release]']' \ - '(--kernel-version -v)'{--kernel-version,-v}'['$_uname_args[kernel-version]']' \ - '(--machine -m)'{--machine,-m}'['$_uname_args[machine]']' \ - '(--processor -p)'{--processor,-p}'['$_uname_args[processor]']' \ - '(--hardware-platform -i)'{--hardware-platform,-i}'['$_uname_args[hardware-platform]']' \ - '(--operating-system -o)'{--operating-system,-o}'['$_uname_args[operating-system]']' \ - '--help['$_uname_args[help]']' \ - '--version['$_uname_args[version]']' -else -# TODO add options of a NON GNU implementation + _arguments -s $args fi diff --git a/Completion/Unix/Command/_uniq b/Completion/Unix/Command/_uniq index dcd7a6f49..1cf12357b 100644 --- a/Completion/Unix/Command/_uniq +++ b/Completion/Unix/Command/_uniq @@ -1,4 +1,4 @@ -#compdef uniq +#compdef uniq guniq local args @@ -20,7 +20,7 @@ args=( if ! _pick_variant gnu=Free\ Soft unix --version; then local optchars="cdufs" - if [[ "$OSTYPE" == (darwin|freebsd)* ]]; then + if [[ "$OSTYPE" == (darwin|dragonfly|freebsd)* ]]; then optchars="${optchars}i" fi args=( ${(M)args:#(|\*)(|\(*\))-[$optchars]*} ) diff --git a/Completion/Unix/Command/_user_admin b/Completion/Unix/Command/_user_admin index 281171d17..31ccbf1c2 100644 --- a/Completion/Unix/Command/_user_admin +++ b/Completion/Unix/Command/_user_admin @@ -45,6 +45,7 @@ if [[ $service = user* ]]; then "(-L -p)-U[unlock user's password]" ) args+=( + '-a[append groups]' '-l[specify new user name]:new username' ':username:_users' ) diff --git a/Completion/Unix/Command/_vcsh b/Completion/Unix/Command/_vcsh index 47dbd9e69..00aed7d28 100644 --- a/Completion/Unix/Command/_vcsh +++ b/Completion/Unix/Command/_vcsh @@ -1,60 +1,29 @@ #compdef vcsh function __vcsh_repositories () { - local expl local -a repos - repos=( ${(f)"$(command vcsh list)"} ) - _describe -t repos 'repositories' repos -} - -function __vcsh_not_implemented_yet () { - _message "Subcommand completion '${1#*-}': not implemented yet" + repos=( ${(f)"$(_call_program repositories vcsh list)"} ) + _describe -t repositories 'repository' repos } function _vcsh-clone () { - __vcsh_not_implemented_yet "$0" #TODO -} - -function _vcsh-delete () { - (( CURRENT == 2 )) && __vcsh_repositories + _default #TODO } -function _vcsh-enter () { - (( CURRENT == 2 )) && __vcsh_repositories -} - -function _vcsh-help () { - _nothing -} - -function _vcsh-init () { - _nothing -} - -function _vcsh-list () { - _nothing -} - -function _vcsh-list-tracked () { - _nothing -} - -function _vcsh-list-tracked-by () { - (( CURRENT == 2 )) && __vcsh_repositories -} - -function _vcsh-pull () { - _nothing -} - -function _vcsh-push () { - _nothing -} +local func +for func in help init list list-tracked pull push version; do + _vcsh-$func() { _nothing } +done +for func in delete enter list-tracked-by upgrade write-gitignore; do + _vcsh-$func() { (( CURRENT == 2 )) && __vcsh_repositories } +done function _vcsh-rename () { - (( CURRENT == 2 )) && __vcsh_repositories - (( CURRENT == 3 )) && _message "new repository name" - (( CURRENT > 3 )) && _nothing + case $CURRENT in + 2) __vcsh_repositories ;; + 3) _message "new repository name" ;; + *) _nothing ;; + esac } function _vcsh-run () { @@ -66,24 +35,8 @@ function _vcsh-run () { fi } -function _vcsh-upgrade () { - (( CURRENT == 2 )) && __vcsh_repositories -} - -function _vcsh-version () { - _nothing -} - -function _vcsh-which () { - _files -} - -function _vcsh-write-gitignore () { - (( CURRENT == 2 )) && __vcsh_repositories -} - function _vcsh () { - local curcontext="${curcontext}" + local curcontext="${curcontext}" ret=1 local state vcshcommand local -a args subcommands @@ -112,24 +65,25 @@ function _vcsh () { '*:: :->subcommand_or_options_or_repo' ) - _arguments -C ${args} && return + _arguments -C ${args} && ret=0 if [[ ${state} == "subcommand_or_options_or_repo" ]]; then if (( CURRENT == 1 )); then - _describe -t subcommands 'vcsh sub-commands' subcommands - __vcsh_repositories + _describe -t subcommands 'vcsh sub-commands' subcommands && ret=0 + __vcsh_repositories && ret=0 else vcshcommand="${words[1]}" if ! (( ${+functions[_vcsh-$vcshcommand]} )); then # There is no handler function, so this is probably the name # of a repository. Act accordingly. - _dispatch git git + _dispatch git git && ret=0 else curcontext="${curcontext%:*:*}:vcsh-${vcshcommand}:" _call_function ret _vcsh-${vcshcommand} fi fi fi + return ret } _vcsh "$@" diff --git a/Completion/Unix/Command/_vim b/Completion/Unix/Command/_vim index 42e5058ec..021054d47 100644 --- a/Completion/Unix/Command/_vim +++ b/Completion/Unix/Command/_vim @@ -1,4 +1,4 @@ -#compdef vim exim gvim gex gview rvim rview rgvim rgview evim eview vimdiff gvimdiff +#compdef vim exim gvim gex gview nvim rvim rview rgvim rgview evim eview vimdiff gvimdiff (( $+functions[_vim_files] )) || _vim_files () { diff --git a/Completion/Unix/Command/_wc b/Completion/Unix/Command/_wc new file mode 100644 index 000000000..49a03ba2c --- /dev/null +++ b/Completion/Unix/Command/_wc @@ -0,0 +1,26 @@ +#compdef wc gwc + +local args + +args=( + '(-c --bytes)'{-c,--bytes}'[print byte counts]' + '(-C -m --chars)'{-m,--chars}'[print character counts]' + '(-w --words)'{-w,--words}'[print word counts]' + '(-l --lines)'{-l,--lines}'[print line counts]' +) + +if _pick_variant gnu=GNU unix --version; then + args+=( + '(*)--files0-from=[read NUL-terminated file list from specified file]:file:_files' + '(-L --max-line-length)'{-L,--max-line-length}'[print longest line lengths]' + ) +else + args=( -A "-*" "${(@)args:#(|\(*\))(|\*)--*}" ) + case $OSTYPE in + freebsd*|netbsd*) args+=( '-L[print longest line lengths]' ) ;; + openbsd*) args+=( '-h[human readable: use unit suffixes]' ) ;; + solaris*) args+=( ${${(M)args:#*-m\[*}//-m\[/-C\[} ) ;; + esac +fi + +_arguments -s -S $args '*:file:_files' diff --git a/Completion/Unix/Command/_xargs b/Completion/Unix/Command/_xargs index f727ed8b7..d8c0a0ec2 100644 --- a/Completion/Unix/Command/_xargs +++ b/Completion/Unix/Command/_xargs @@ -1,15 +1,63 @@ -#compdef xargs - -_arguments \ - '(-t)-p[prompt user for each command]' \ - '(-p)-t[verbose - echo each command]' \ - '-x[exit if max size exceeded]' \ - -{e-,E}':end-of-file string:' \ - '(-x -I)-i-:replacement string for lines:' \ - '(-x -i)-I:replacement string for lines:' \ - '(-n -L -x)-l-:number of input lines:' \ - '(-n -l)-L:number of input lines:' \ - '(-l -L)-n-:maximum number of arguments:' \ - '-s-:maximum command line length:' \ +#compdef xargs gxargs + +local args variant + +args=( + '(-l -L --max-lines -n --max-args -s --max-chars)'{-n+,--max-args=}'[specify maximum number of arguments for each line]:number of arguments' \ + '(-l -L --max-lines -n --max-args -s --max-chars)'{-s+,--max-chars=}'[specify maximum characters per command line]:maximum command line length' + '(-p --verbose -t --interactive)'{-p,--interactive}'[prompt user for each command]' + '(-p --verbose -t --interactive)'{-t,--verbose}'[verbose - echo each command]' + '(-x --exit)'{-x,--exit}'[exit if max size exceeded]' +) + +_pick_variant -r variant gnu=GNU $OSTYPE --version + +case $variant in + gnu|darwin*|freebsd*|netbsd*|openbsd*) + args+=( + '(--max-procs -P)'{-P,--max-procs}'[parallel mode]:maximum processes' '!-r' + ) + ;| + dragonfly*|darwin*|freebsd*|netbsd*|openbsd*) + args=( "${(@)args:#(|\(*\))(|\*)--*}" + '-0[expect NUL characters as input separators]' + '-J[specify marker for position of arguments]:marker' + '-R[specify maximum arguments that -I will replace in]:replacements' + ) + ;| + freebsd*|netbsd*) + args+=( + '-S[space that -I can use for replacements]:size (bytes) [255]' + ) + ;; + solaris*|gnu) + args+=( + '(-x -I)'{-i-,--replace}'[specify replacement string for command line]::replacement string' + '(-n -L -x)-l-[call program for every number of lines]:number of input lines' + '(-E -e --eof)'{-e-,--eof=}'[specify EOF marker]:end-of-file marker' + ) + ;| + solaris*) args=( "${(@)args:#(|\(*\))(|\*)--*}" ) ;| + solaris2.<11->) + args+=( '-0[expect NUL characters as input separators]' ) + ;; + gnu) + args+=( + '(-a --arg-file)'{-a+,--arg-file=}'[read input items from specified file]:file:_files' + '(-0 --null -d --delimiter)'{-0,--null}'[expect NUL characters as input separators]' + '(-d --delimiter -0 --null)'{-d+,--delimiter=}'[specify delimiter of input items]:delimiter' + '(-l -L --max-lines -n --max-args -s --max-chars)--max-lines=-[call program for every number of lines]::number of input lines' + '(-r --no-run-if-empty)'{-r,--no-run-if-empty}"[don't run command in absence of input]" + '(- *)--help[show help information]' + '(- *)--version[show version information]' + '--show-limits[show OS imposed limits to command-line length]' + ) + ;; +esac + +_arguments -s $args \ + '-E[specify EOF marker]:end-of-file marker' \ + '(-x -i)-I[specify replacement string for command line]:replacement string' \ + '(-n -l)-L[call program for every number of lines]:number of input lines' \ '(-):command: _command_names -e' \ '*::args: _normal' diff --git a/Completion/Unix/Command/_xxd b/Completion/Unix/Command/_xxd new file mode 100644 index 000000000..1a822553c --- /dev/null +++ b/Completion/Unix/Command/_xxd @@ -0,0 +1,45 @@ +#compdef xxd + +local arguments + +# Output options compatibility matrix +# +# 0 - options conflict +# 1 - options coexist +# +# (The matrix is symmetric, so implied values are not shown.) +# +# bEipru +# bx10000 +# E-x0001 +# i--x001 +# p---x11 +# r----x0 +# u-----x + +# xxd supports either double or single dashes on long options. +[[ -prefix -- ]] && compset -P - + +arguments=( + # output options + '(-b -bits -i -include -p -postscript -plain -ps -r -reverse -u -uppercase)'{-b,-bits}'[output in binary digits, rather than hex]' + '( -E -EBCDIC -i -include -p -postscript -plain -ps -r -reverse )'{-E,-EBCDIC}'[print human-readable part in EBCDIC rather than ASCII]' + '(-b -bits -E -EBCDIC -i -include -p -postscript -plain -ps -r -reverse )'{-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 -r -reverse -u -uppercase)'{-r,-reverse}'[reverse mode\: read a hex dump and output binary data]' + '(-b -bits -r -reverse -u -uppercase)'{-u,-uppercase}'[output upper-case hex digits]' + + {-h,-help}'[display usage message]' + {-v,-version}'[show program version]' + '*'{-a,-autoskip}"[a single '*' replaces runs of NUL (toggleable)]" + + {-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"' + {-s,-skip,-seek}'[specify file offset to dump from]: :_guard "[0-9]#" "file offset to dump from (absolute or relative)"' + + ':files:_files' +) + +_arguments -S $arguments diff --git a/Completion/Unix/Command/_zpool b/Completion/Unix/Command/_zpool index 0f18eefb5..03ebd0642 100644 --- a/Completion/Unix/Command/_zpool +++ b/Completion/Unix/Command/_zpool @@ -12,7 +12,7 @@ _zpool() { ) versions=( - ${${${(M)"${(f)$(zpool upgrade -v)}":#[[:space:]]#<->*}##[[:space:]]}%%[[:space:]]*} + ${${${(M)"${(f)$(_call_program versions zpool upgrade -v)}":#[[:space:]]#<->*}##[[:space:]]}%%[[:space:]]*} ) ro_props=( @@ -87,15 +87,12 @@ _zpool() { if [[ $service == "zpool" ]]; then _arguments -C -A "-*" \ - '-\?[Help]' \ - '*::command:->subcmd' && return 0 + '-\?[show help information]' \ + '1:subcommand:compadd -a subcmds' \ + '*:: :->subcmd' && return - if (( CURRENT == 1 )); then - _wanted commands expl "zpool subcommand" compadd -a subcmds - return - fi service="$words[1]" - curcontext="${curcontext%:*}=$service:" + curcontext="${curcontext%:*}-$service:" fi case $service in diff --git a/Completion/Unix/Type/_cmdstring b/Completion/Unix/Type/_cmdstring new file mode 100644 index 000000000..fb19fdb76 --- /dev/null +++ b/Completion/Unix/Type/_cmdstring @@ -0,0 +1,6 @@ +#autoload + +# This is for a quoted argument that will be interpreted as a command. + +compset -q +_normal diff --git a/Completion/Unix/Type/_diff_options b/Completion/Unix/Type/_diff_options index 472838cda..d76c265ca 100644 --- a/Completion/Unix/Type/_diff_options +++ b/Completion/Unix/Type/_diff_options @@ -103,17 +103,20 @@ if _pick_variant -c $cmd gnu=GNU unix -v; then else case $OSTYPE in solaris2.<9->) - args=( '(-c -e -f -C)-u[output a unified diff]' ) + args=( + '(-c -e -f -C -U)-u[output a unified diff]' + '(-c -e -f -C -u)-U[output a unified diff]:lines of context' + ) ;& solaris*) args+=( '-i[case insensitive]' '-t[expand tabs to spaces]' '-w[ignore all white space]' - '(-c -e -f -n -u -h -D)-C+[output a context diff]:number of lines of copied context' - '(-c -e -f -n -u -C -D)-h[do a fast, half-hearted job]' - '(-c -e -f -u -h -C -D)-n[reversed ed script]' - '(-c -e -f -n -u -h -C)-D[output merged file with preprocessor directives]:preprocessor symbol' + '(-c -e -f -n -u -U -h -D)-C+[output a context diff]:lines of context' + '(-c -e -f -n -u -U -C -D)-h[do a fast, half-hearted job]' + '(-c -e -f -u -U -h -C -D)-n[reversed ed script]' + '(-c -e -f -n -u -U -h -C)-D[output merged file with preprocessor directives]:preprocessor symbol' '-l[output through pr]' '-s[report on identical files]' '-S+[set first file in comparison]:start with file:_files' diff --git a/Completion/Unix/Type/_directories b/Completion/Unix/Type/_directories index ab1b50b4f..2125645fe 100644 --- a/Completion/Unix/Type/_directories +++ b/Completion/Unix/Type/_directories @@ -1,4 +1,4 @@ -#compdef rmdir df dircmp -P -value-,*path,-default- +#compdef rmdir zf_rmdir dircmp -P -value-,*path,-default- local expl diff --git a/Completion/Unix/Type/_file_systems b/Completion/Unix/Type/_file_systems index 3415bb163..2d903d471 100644 --- a/Completion/Unix/Type/_file_systems +++ b/Completion/Unix/Type/_file_systems @@ -12,18 +12,19 @@ case $OSTYPE in [[ -r /proc/filesystems ]] && fss+=( ${$(</proc/filesystems)#nodev} ) [[ -r /etc/filesystems ]] && - fss+=( ${$(</etc/filesystems)#\*} ) + fss+=( ${${${(f)"$(</etc/filesystems)"}:#\#*}#\*} ) ;; osf*) fss=( advfs ufs nfs mfs cdfs ) ;; solaris*) fss=( ufs nfs hsfs s5fs pcfs cachefs tmpfs ) ;; dragonfly*) - fss=( cd9660 devfs ext2fs fdesc kernfs linprocfs mfs msdos nfs + fss=( cd9660 devfs ext2fs fdesc kernfs linprocfs mfs msdos nfs ntfs null nwfs portal procfs std udf ufs umap union ) ;; freebsd*) + fss=( ${${(f)"$(_call_program fstypes lsvfs)"}[3,-1]%% *} ) || fss=( cd9660 devfs ext2fs fdescfs kernfs linprocfs linsysfs mfs msdosfs nfs - ntfs nullfs nwfs portalfs procfs smbfs std udf ufs unionfs - reiserfs xfs) + ntfs nullfs nwfs portalfs procfs smbfs std tmpfs udf ufs unionfs + reiserfs xfs zfs ) ;; darwin*) fss=( afp cd9660 cddafs devfs fdesc hfs lfs msdos nfs @@ -36,11 +37,3 @@ case $OSTYPE in esac _wanted fstypes expl 'file system type' compadd "$@" -M 'L:|no=' -a "$@" - fss - - - - - - - - diff --git a/Completion/Unix/Type/_files b/Completion/Unix/Type/_files index 0f6fcd6ff..e628cb39e 100644 --- a/Completion/Unix/Type/_files +++ b/Completion/Unix/Type/_files @@ -121,9 +121,13 @@ for def in "$pats[@]"; do if _path_files -g "$pat" "$opts[@]" "$expl[@]"; then ret=0 elif [[ $PREFIX$SUFFIX != */* ]] && zstyle -a ":completion:${curcontext}:$tag" recursive-files rfiles; then + local subtree for rfile in $rfiles; do if [[ $PWD/ = ${~rfile} ]]; then - for prepath in **/*(/); do + if [[ -z $subtree ]]; then + subtree=( **/*(/) ) + fi + for prepath in $subtree; do oprefix=$PREFIX PREFIX=$prepath/$PREFIX _path_files -g "$pat" "$opts[@]" "$expl[@]" && ret=0 diff --git a/Completion/Unix/Type/_find_net_interfaces b/Completion/Unix/Type/_find_net_interfaces new file mode 100644 index 000000000..0c7033519 --- /dev/null +++ b/Completion/Unix/Type/_find_net_interfaces @@ -0,0 +1,42 @@ +#autoload + +# This can be called independently of completion. It returns +# arrays net_intf_disp and net_intf_list which the caller should +# make local. + +local sep list + +# Make sure needed tools are in the path. +local PATH=$PATH +PATH=/sbin:$PATH + +case $OSTYPE in + aix*) + net_intf_list=( ${(f)"$(lsdev -C -c if -F 'name:description')"} ) + if zstyle -T ":completion:${curcontext}" verbose; then + zstyle -s ":completion:${curcontext}:" list-separator sep || sep=-- + zformat -a list " $sep " "$net_intf_list[@]" + net_intf_disp=(-ld list) + fi + ;; + darwin*|freebsd*|dragonfly*) net_intf_list=( $(ifconfig -l) ) ;; + irix*) net_intf_list=( ${${${(f)"$(/usr/etc/netstat -i)"}%% *}[2,-1]} ) ;; + *linux*) + if (( $+commands[ip] )); then + net_intf_list=( ${${(m)${(f)"$(ip -o link)"}#*: }%%: *} ) + fi + ;& + + *) + if [[ ${#net_intf_list} -eq 0 ]]; then + # linux's deprecated ifconfig may truncate long interface names + net_intf_list=( $(ifconfig -a 2>/dev/null | sed -n 's/^\([^ :]*\).*/\1/p') ) + if [[ -d /proc/sys/net/ipv4/conf ]]; then + # On linux we used to use the following as the default. + # However, we now use ip or ifconfig since it finds additional devices such + # as tunnels. So only do this if that didn't work. + net_intf_list=( /proc/sys/net/ipv4/conf/*~*(all|default)(N:t) ) + fi + fi + ;; +esac diff --git a/Completion/Unix/Type/_net_interfaces b/Completion/Unix/Type/_net_interfaces index 2cac3e3bb..5be66d7d1 100644 --- a/Completion/Unix/Type/_net_interfaces +++ b/Completion/Unix/Type/_net_interfaces @@ -1,42 +1,9 @@ #compdef ifup ifdown -local expl list intf sep -local -a disp +local expl +local -a net_intf_disp net_intf_list -# Make sure needed tools are in the path. -local PATH=$PATH -PATH=/sbin:$PATH - -case $OSTYPE in - aix*) - intf=( ${(f)"$(lsdev -C -c if -F 'name:description')"} ) - if zstyle -T ":completion:${curcontext}" verbose; then - zstyle -s ":completion:${curcontext}:" list-separator sep || sep=-- - zformat -a list " $sep " "$intf[@]" - disp=(-ld list) - fi - ;; - darwin*|freebsd*|dragonfly*) intf=( $(ifconfig -l) ) ;; - irix*) intf=( ${${${(f)"$(/usr/etc/netstat -i)"}%% *}[2,-1]} ) ;; - *linux*) - if (( $+commands[ip] )); then - intf=( ${${(m)${(f)"$(ip -o link)"}#*: }%%: *} ) - fi - ;& - - *) - if [[ ${#intf} -eq 0 ]]; then - # linux's deprecated ifconfig may truncate long interface names - intf=( $(ifconfig -a 2>/dev/null | sed -n 's/^\([^ :]*\).*/\1/p') ) - if [[ -d /proc/sys/net/ipv4/conf ]]; then - # On linux we used to use the following as the default. - # However, we now use ip or ifconfig since it finds additional devices such - # as tunnels. So only do this if that didn't work. - intf=( /proc/sys/net/ipv4/conf/*~*(all|default)(N:t) ) - fi - fi - ;; -esac +_find_net_interfaces _wanted interfaces expl 'network interface' \ - compadd "$@" "$disp[@]" - "${(@)intf%%:*}" + compadd "$@" "$net_intf_disp[@]" - "${(@)net_intf_list%%:*}" diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files index ed3f54de3..c64ebf58c 100644 --- a/Completion/Unix/Type/_path_files +++ b/Completion/Unix/Type/_path_files @@ -609,8 +609,15 @@ for prepath in "$prepaths[@]"; do tmp3="$pre$suf" tpre="$pre" tsuf="$suf" - [[ -n "${prepath}${realpath}${testpath}" ]] && + if [[ -n "${prepath}${realpath}${testpath}" ]] + then + if [[ -o nocaseglob ]] + then + tmp1=( "${(@)tmp1#(#i)${prepath}${realpath}${testpath}}" ) + else tmp1=( "${(@)tmp1#${prepath}${realpath}${testpath}}" ) + fi + fi while true; do diff --git a/Completion/Unix/Type/_pdf b/Completion/Unix/Type/_pdf index f20f94e79..60cee84ee 100644 --- a/Completion/Unix/Type/_pdf +++ b/Completion/Unix/Type/_pdf @@ -1,4 +1,4 @@ -#compdef pdf2dsc pdf2ps pdfimages pdfinfo pdftopbm pdftops pdftotext pdfopt pdffonts kpdf apvlv evince epdfview +#compdef pdf2dsc pdf2ps pdfimages pdfinfo pdftopbm pdftops pdftotext pdfopt pdffonts kpdf apvlv epdfview local expl ext='' diff --git a/Completion/Unix/Type/_perl_modules b/Completion/Unix/Type/_perl_modules index 1b61043e7..d27a7f7af 100644 --- a/Completion/Unix/Type/_perl_modules +++ b/Completion/Unix/Type/_perl_modules @@ -71,7 +71,7 @@ _perl_modules () { perl_modules=_unknown_perl_modules$with_pod fi - if ( [[ ${(P)+perl_modules} -eq 0 ]] || _cache_invalid $perl_modules ) && + if ( [[ ${(P)+perl_modules} -eq 0 ]] || _cache_invalid ${perl_modules#_} ) && ! _retrieve_cache ${perl_modules#_}; then if zstyle -t ":completion:${curcontext}:modules" try-to-use-pminst && diff --git a/Completion/Unix/Type/_pids b/Completion/Unix/Type/_pids index 3c6a76561..cf9000538 100644 --- a/Completion/Unix/Type/_pids +++ b/Completion/Unix/Type/_pids @@ -1,4 +1,4 @@ -#compdef pflags pcred pmap pldd psig pstack pfiles pwdx pstop prun pwait ptree +#compdef pflags pcred pmap pldd psig pstack pfiles pwdx pstop prun pwait # If given the `-m <pattern>' option, this tries to complete only pids # of processes whose command line match the `<pattern>'. diff --git a/Completion/Unix/Type/_python_modules b/Completion/Unix/Type/_python_modules new file mode 100644 index 000000000..b30848d83 --- /dev/null +++ b/Completion/Unix/Type/_python_modules @@ -0,0 +1,44 @@ +#autoload + +_python_module_caching_policy () { + local -a newer + # rebuild if cache does not exist or is more than a week old + newer=( "$1"(Nmw-1) ) + return $#newer +} + +_python_modules () { + local update_policy python expl + + case $words[1] in + (python*) python=$words[1] ;; + (pydoc*) python=${words[1]/#pydoc/python} ;; + (*) python="python" ;; + esac + local cache_id=${${python//[^[:alnum:]]/_}#_}_modules + local array_name=_${cache_id} + + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + [[ -z "$update_policy" ]] && \ + zstyle ":completion:${curcontext}:" \ + cache-policy _python_module_caching_policy + + if ( [[ ${(P)+array_name} -eq 0 ]] || _cache_invalid $cache_id ) && + ! _retrieve_cache $cache_id; then + + local script='import sys, pydoc +def f(p,m,d): + if m.find(".") < 0: sys.stdout.write(m+"\n") +pydoc.ModuleScanner().run(f)' + + typeset -agU $array_name + set -A $array_name \ + $(_call_program modules $python -c ${(q)script} 2>/dev/null) + + _store_cache $cache_id $array_name + fi + + _wanted modules expl module compadd "$@" -a -- $array_name +} + +_python_modules "$@" diff --git a/Completion/Unix/Type/_users b/Completion/Unix/Type/_users index 3c8c7027b..2ea3b1455 100644 --- a/Completion/Unix/Type/_users +++ b/Completion/Unix/Type/_users @@ -3,8 +3,8 @@ local expl users if zstyle -a ":completion:${curcontext}:users" users users; then - _wanted users expl user compadd "$@" -a - users - return 0 + _wanted users expl user compadd "$@" -a - users + return fi _wanted users expl user compadd "$@" -k - userdirs diff --git a/Completion/X/Command/_rdesktop b/Completion/X/Command/_rdesktop new file mode 100644 index 000000000..0bd08d932 --- /dev/null +++ b/Completion/X/Command/_rdesktop @@ -0,0 +1,71 @@ +#compdef rdesktop + +local curcontext="$curcontext" state line expl redir ret=1 +typeset -A opt_args + +_arguments -C -s \ + '-u[username]:username:_users' \ + '-d[domain]:domain' \ + '-s[shell]:startup shell' \ + '-c[working directory]:directory:_directories' \ + '-p[password]:password' \ + '-n[hostname]:host:_hosts' \ + '-k[keyboard map]:keyboard map' \ + '(-f)-g[geometry]:geometry (WxH)' \ + '(-g)-f[fullscreen mode]' \ + '-b[force server to use bitmaps for screen updates]' \ + '-B[use X server backing store]' \ + '-E[disable encryption]' \ + "-m[don't send mouse motion events]" \ + '-C[use private colormap]' \ + '-D[hide window decorations]' \ + '-K[do not override window manager key bindings]' \ + '-S[single application mode]' \ + '-T[set window title]:title' \ + '-N[enable numlock synchronisation]' \ + '-X[embed in another window]:window:_x_window' \ + '-a[colour depth]:depth:(8 15 16 24)' \ + '-z[enable compression]' \ + '-x[bandwidth performance behaviour]:experience:((b\:broadband l\:lan m\:modem))' \ + '-P[enable bitmap caching]' \ + '*-r[device redirection]: :->redirection' \ + '-0[attach to server console]' \ + '(-5)-4[use RDP version 4]' \ + '(-4)-5[use RDP version 5]' \ + ':server:->hostsport' && ret=0 + +case $state in + hostsport) + if compset -P '*:'; then + _ports && ret=0 + else + compset -S ':*' + _hosts && ret=0 + fi + ;; + redirection) + redir="${PREFIX%%:*}" + if compset -P '*='; then + curcontext="${curcontext%:*}:$redir" + compset -P '*=' + case $redir in + comport|lptport) _wanted devices expl device _files -g '*(-%)' && ret=0 ;; + disk) _directories && ret=0 ;; + printer) _printers && ret=0 ;; + scard) _message -e aliases 'alias name' ;; + esac + else + compset -S '=*' + _values -S : 'redirection' \ + 'comport:port' \ + 'disk:sharename' \ + 'lptport:lptport' \ + 'printer:printername:_printers -S=' \ + 'sound:sound:(local off remote)' \ + 'lspci' \ + 'scard:sound card name' && ret=0 + fi + ;; +esac + +return ret diff --git a/Completion/X/Command/_urxvt b/Completion/X/Command/_urxvt index b7ea06be5..661897c3a 100644 --- a/Completion/X/Command/_urxvt +++ b/Completion/X/Command/_urxvt @@ -1,6 +1,6 @@ -#compdef rxvt urxvt urxvtc +#compdef rxvt urxvt urxvtc urxvt256c urxvt256cc urxvt256c-ml urxvt256c-mlc -local curcontext="$curcontext" state line expl +local curcontext="$curcontext" state line expl ret=1 local -a suf long_args typeset -A opt_args typeset -U extensions diff --git a/Completion/X/Command/_x_utils b/Completion/X/Command/_x_utils index 9448fd3df..05a899b68 100644 --- a/Completion/X/Command/_x_utils +++ b/Completion/X/Command/_x_utils @@ -1,12 +1,13 @@ #compdef xdpyinfo xwininfo xkill xfontsel xfd xev xhost xon xsetroot xwd xwud xrdb xprop xlsatoms -local ret=1 oret expl +local curcontext="$curcontext" state line expl ret=1 case "$service" in xdpyinfo) _x_arguments \ -queryExtensions \ - '-ext:extension: _x_extension -a' + '-ext:extension: _x_extension -a' \ + -version ;; xwininfo) _x_arguments \ @@ -16,7 +17,7 @@ xwininfo) '(-name -root)-id:id: _x_window' ;; xprop) - _x_arguments \ + _x_arguments -C \ -{help,frame,notype,spy} \ '-grammar[show grammar for command line options]' \ '(-id -name)-root[use the root window as the target window]' \ @@ -28,16 +29,17 @@ xprop) '*-remove[specify an atom to remove from the target window]:atoms:->atoms' \ '*-set[specify an atom and a value to set on the target window]:atoms:->atoms:value' \ '*-f:atoms:->atoms:format: ::dformat' \ - '*:atoms:->atoms' && ret=0 + '*:atoms:->atoms' ;; xlsatoms) - _x_arguments \ + _x_arguments -C \ '*-format[printf-style format to use]:format' \ '*-range[atom values to list]:[num]-[num]' \ '*-name[name of single atom to print]:atom:->atoms' ;; xkill) _x_arguments \ + -version \ -frame \ '(-id)-all' \ '(-all)-id:window: _x_window' \ @@ -45,14 +47,16 @@ xkill) ;; xfontsel) _xt_arguments \ - -{print,noscaled} \ + -{print,scaled} \ '-pattern:font pattern:_x_font' \ '-sample:sample text' \ - '-sample16:16-bit sample text' + '-sample16:16-bit sample text' \ + '-sampleUCS:ISO10646 sample text' ;; xfd) _xt_arguments \ '-fn:font: _x_font' \ + '-fa:font: _xft_fonts' \ -{box,center} \ '-start:first character number' \ '-bc:box border color:_x_color' \ @@ -66,7 +70,8 @@ xev) '-id:id:_x_window' \ '-s[use save-under]' \ '-name:window name' \ - '-rv' + '-rv' \ + '*-event:event mask:(keyboard mouse expose visibility structure substructure focus property colormap owner_grab_button randr)' ;; xhost) local type tmp match @@ -120,8 +125,8 @@ xhost) 'types:name family:compadd -S: - inet dnet nis krb' \ 'hosts:: _hosts' && ret=0 fi - return ret fi + return ret ;; xon) _arguments \ @@ -165,7 +170,7 @@ xwud) ;; xrdb) _x_arguments \ - -{help,quiet,symbols,retain} \ + -{help,quiet,symbols,retain,version} \ '(-all -screen -screens)-global' \ '(-global -screen -screens)-all' \ '(-global -all -screens)-screen' \ @@ -185,12 +190,10 @@ xrdb) '*-I-:include directory:_files -/' \ '*:defaults file:_files' ;; -esac +esac && ret=0 -oret=$? if [[ $state == atoms ]]; then _wanted atoms expl atoms compadd ${${(f)"$(_call_program atoms xlsatoms 2> /dev/null)"}#*$'\t'} && ret=0 -else - ret=$oret fi + return ret diff --git a/Completion/X/Command/_xautolock b/Completion/X/Command/_xautolock new file mode 100644 index 000000000..4d01a1dd2 --- /dev/null +++ b/Completion/X/Command/_xautolock @@ -0,0 +1,25 @@ +#compdef xautolock +_arguments \ + '(-enable -toggle)-disable' \ + '(-disable -toggle)-enable' \ + '(-locknow)-unlocknow' \ + '(-unlocknow)-locknow' \ + '(-restart)-exit' \ + '(-exit)-restart' \ + '-killer:program: _command_names -e' \ + '-locker:program: _command_names -e' \ + '-notifier:program: _command_names -e' \ + '-nowlocker:program: _command_names -e' \ + -bell:percent: \ + -cornerdelay:seconds: \ + -cornerredelay:seconds: \ + -corners:corners: \ + -cornersize:pixels: \ + -killtime:minutes: \ + -noclose{,out,err} \ + -notify:seconds: \ + -time:minutes: \ + -secure \ + -resetsaver \ + -detectsleep \ + -{help,version} diff --git a/Completion/Zsh/Command/_bindkey b/Completion/Zsh/Command/_bindkey index 045cba960..4c4aeda9d 100644 --- a/Completion/Zsh/Command/_bindkey +++ b/Completion/Zsh/Command/_bindkey @@ -26,6 +26,7 @@ _arguments -C -s -S \ '(-l -L -d -D -A -N -m -s *)-r[unbind specified in-strings]:*:in-string' \ '(-l -L -d -D -A -N -m -p -r *)-s[bind each in-string to each out-string]:*:key string' \ '(-e -v -a -M -l -L -d -D -A -N -m -p)-R[interpret in-strings as ranges]' \ + '(-l -L -d -A -N -m -p -r -s):in-string' \ '(-l -L -d -A -N -m -p -r -s)*::widgets:->widget' && ret=0 case $state in diff --git a/Completion/Zsh/Command/_command b/Completion/Zsh/Command/_command index 7cfb52c2f..4e2858676 100644 --- a/Completion/Zsh/Command/_command +++ b/Completion/Zsh/Command/_command @@ -1,14 +1,11 @@ #compdef command -local ret - # indicate if this is a precommand modifier [[ $service = command ]] && precommands+=(command) -if [[ CURRENT -ge 3 ]]; then - compset -n 2 - _normal && ret=0 -else - _path_commands "$@" && ret=0 -fi -return ret +_arguments \ + '-v[indicate result of command search]:*:command:_path_commands' \ + '-V[show result of command search in verbose form]:*:command:_path_commands' \ + '(-)-p[use default PATH to find command]' \ + ':command:_path_commands' \ + '*::arguments: _normal' diff --git a/Completion/Zsh/Command/_emulate b/Completion/Zsh/Command/_emulate index e562d6834..d6fb0c3d9 100644 --- a/Completion/Zsh/Command/_emulate +++ b/Completion/Zsh/Command/_emulate @@ -1,6 +1,8 @@ #compdef emulate -_arguments -C -s -A "-*" \ +_arguments -C -s \ '-L[set local_options and local_traps as well]' \ '-R[reset all options instead of only those needed for script portability]' \ - '::shell to emulate:(zsh sh ksh csh)' + '1:shell to emulate:(zsh sh ksh csh)' \ + '2:specify optional command:(-c)' \ + '3:command:_cmdstring' diff --git a/Completion/Zsh/Command/_fc b/Completion/Zsh/Command/_fc index 2af5980c2..c2987211e 100644 --- a/Completion/Zsh/Command/_fc +++ b/Completion/Zsh/Command/_fc @@ -1,21 +1,47 @@ #compdef fc history r +local curcontext="$curcontext" state state_descr line ret=1 +local list events num cmd +typeset -A opt_args local fc_common fc_hist fc_r +# hide any replacements from _arguments +local cur=${(M)#words[1,CURRENT-1]:#*=*} +words=( "${(@)words[1,CURRENT-1]:#*=*}" "${(@)words[CURRENT,-1]}" ) +(( CURRENT -= cur )) + fc_common=( + -s -S '(-A -R -W -I -p -P)-r[reverse order of the commands]' '(-A -R -W -I -e -p -P)-n[suppress line numbers]' - '(-A -R -W -I -p -P)*::commands:_command_names -e' ) +) + +if [[ -n ${words[(r)-[pa](|[ap])]} ]]; then + fc_common+=( + ':history file:_files' + ':history size:' + ':saved history size:' + ) + [[ -n ${words[(r)-(|a)p(|a)]} ]] || fc_common+='!-a:option:(-p)' +elif [[ -n ${words[(r)-*[ARWI]*]} ]]; then + fc_common+=( ':history file:_files' ) +else + fc_common=( -C "$fc_common[@]" + '(-)1:first event:->events' '2:last event:->events' + ) +fi fc_hist=( - '(-A -R -W -I -p -p)-m[treat first argument as a pattern]' - '(-A -R -W -I -e -f -E -i -t -p -P)-d[print time-stamps]' - '(-A -R -W -I -e -d -E -i -t -p -P)-f[mm/dd/yyyy format time-stamps]' - '(-A -R -W -I -e -d -f -i -t -p -P)-E[dd.mm.yyyy format time-stamps]' - '(-A -R -W -I -e -d -f -E -t -p -P)-i[yyyy-mm-dd format time-stamps]' - '(-A -R -W -I -e -d -f -E -i -p -P)-t[print time-stamps in specified format]:date format' - '(-A -R -W -I -e -p -P)-D[print elapsed times]' - '(- *)-p[push current history to stack]:history file:_files:history size: :saved history size' + '(-A -R -W -I -a -p -P 2)-m[treat argument as a pattern]' + '(-A -R -W -I -e -f -E -i -t -a -p -P)-d[print time-stamps]' + '(-A -R -W -I -e -d -E -i -t -a -p -P)-f[mm/dd/yyyy format time-stamps]' + '(-A -R -W -I -e -d -f -i -t -a -p -P)-E[dd.mm.yyyy format time-stamps]' + '(-A -R -W -I -e -d -f -E -t -a -p -P)-i[yyyy-mm-dd format time-stamps]' + '(-A -R -W -I -e -d -f -E -i -a -p -P)-t[print time-stamps in specified format]:date format' + '(-A -R -W -I -e -a -p -P)-D[print elapsed times]' + + '(-A -R -W -I -e -d -f -i -l -m -n -r -D -E -t -P)-a[with -p, automatically pop history on function return]' + '(-A -R -W -I -e -d -f -i -l -m -n -r -D -E -t -P)-p[push current history to stack]' '(- *)-P[pop history from stack]' ) @@ -23,18 +49,42 @@ fc_r='(-A -R -W -I -e)-l[list resulting commands on stdout]' case $service in history) - _arguments -s -S "$fc_common[@]" "$fc_hist[@]" && return 0 + _arguments "$fc_common[@]" "$fc_hist[@]" && ret=0 ;; r) - _arguments -s -S "$fc_common[@]" "$fc_r" && return 0 + _arguments "$fc_common[@]" "$fc_r" && ret=0 ;; *) - _arguments -s -S \ - '(-A -R -W -I -l -n -d -f -E -i -D -p -P)-e[specify editor to invoke]:editor to invoke:_command_names -e' \ - '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-R[read history from file]:history file:_files' \ - '(-l -m -e -r -n -d -f -E -i -D -R -W -p -P *)-A[append history to file]:history file:_files' \ - '(-l -m -e -r -n -d -f -E -i -D -R -A -p -P *)-W[write history to file]:history file:_files' \ - '(-l -m -e -r -n -d -f -E -i -D -A -W -p -P *)-I[read/write new events only]:history file:_files' \ - "$fc_common[@]" "$fc_hist[@]" "$fc_r" && return 0 + _arguments "$fc_common[@]" "$fc_hist[@]" "$fc_r" \ + '(-A -R -W -I -a -l -n -d -f -E -i -r -t -D -p -P)-e+[specify editor to invoke]:editor to invoke:_command_names -e' \ + '(-a -l -m -e -r -n -d -f -t -E -i -R -D -A -W -p -P *)-'{\ +'R[read history from file]',\ +'A[append history to file]',\ +'W[write history to file]',\ +'I[read/write new events only]'} && ret=0 ;; esac + +if [[ -n $state ]]; then + if [[ -z ${line:#*=*} ]] && compset -P '*='; then + _message -e replacements 'replacement' + elif [[ -prefix [0-9] ]]; then + events=( ${(ps.\0.)"$(printf '%s:%s\0' ${(kv)history})"} ) + zformat -a list " -- " "$events[@]" + _wanted -2V events expl "$state_descr" compadd -M "B:0=" -ld list - \ + "${events[@]%%:*}" + elif [[ -prefix - ]]; then + for num cmd in ${(kv)history}; do + (( num=num - HISTNO )) + events+=( $num:$cmd ) + done + zformat -a list " -- " "$events[@]" + _wanted -2V events expl "$state_descr" compadd -ld list - \ + "${events[@]%%:*}" + else + _wanted events expl "$state_descr" compadd -S '' - \ + ${${history%%[=[:IFS:]]*}:#[0-9-]*} || _guard "[0-9]#" event + fi +fi && ret=0 + +return ret diff --git a/Completion/Zsh/Command/_tcpsys b/Completion/Zsh/Command/_tcpsys index dcc6f6cc8..1240ffbf8 100644 --- a/Completion/Zsh/Command/_tcpsys +++ b/Completion/Zsh/Command/_tcpsys @@ -1,16 +1,16 @@ #compdef tcp_open -local context line expl nm=$compstate[nmatches] -local -a state argargs sesslist +local curcontext="$curcontext" state line expl local -A opt_args +local -a argargs sesslist case $service in (tcp_open) argargs=( '(-a -f -l)-s[open session(s)]' '(-a -f -s)-l[open list of sessions]' - '(-f -s -l)-a[open session for accept on fd]:fd:->fd' - '(-a -s -l)-f[open session for accept on fd]:fd:->fd' + '(-f -s -l)-a[open session for accept on fd]:fd' + '(-a -s -l)-f[open session for accept on fd]:fd' '-q[quiet mode]' '-z[no zle handler]' ) @@ -19,7 +19,7 @@ case $service in elif [[ -n $words[(R)-(l|s)*] ]]; then argargs+=('*:session:->session') else - argargs+=(':host:->host' ':port:->port' '*:session:->session') + argargs+=(':host:_hosts' ':port:_ports' '*:session:->session') fi _arguments -C $argargs ;; @@ -27,14 +27,6 @@ esac while (( $#state )); do case "$state[1]" in - (host) - _hosts - ;; - - (port) - _ports - ;; - (sessionlist) compset -P '*,' ;& diff --git a/Completion/Zsh/Command/_typeset b/Completion/Zsh/Command/_typeset index 367dbfc23..4e29c23e7 100644 --- a/Completion/Zsh/Command/_typeset +++ b/Completion/Zsh/Command/_typeset @@ -46,7 +46,7 @@ use="AEFHLRTUZafghiklmprtuxz" case ${service} in autoload) - use="UXktwz" + use="UTXktwz" func=f ;; float) use="EFHghlprtux";; diff --git a/Completion/Zsh/Command/_unhash b/Completion/Zsh/Command/_unhash index c05c27ea3..ff0c03f49 100644 --- a/Completion/Zsh/Command/_unhash +++ b/Completion/Zsh/Command/_unhash @@ -1,14 +1,9 @@ #compdef unhash -local expl state line curcontext="$curcontext" - -_arguments -C -s -S \ - '(-a -f -s *)-d[remove named directories]:*:named directory:->nameddir' \ +_arguments -s -S \ + '(-a -f -s *)-d[remove named directories]:*:named directory:compadd -k nameddirs' \ '(-d -f -s *)-a[remove aliases]:*:alias:_aliases' \ '(-a -d -f *)-s[remove suffix aliases]:*:suffix alias:_aliases -s s' \ '(-d -a -s *)-f[remove functions]:*:shell function:_functions' \ '-m[treat arguments as patterns]' \ - '(-a -d -f -m)*:command: _command_names -e' && return 0 - -[[ "$state" = nameddir ]] && - _wanted named-directories expl 'named directory' compadd -k nameddirs + '(-a -d -f -m)*:command: _command_names -e' diff --git a/Completion/Zsh/Command/_which b/Completion/Zsh/Command/_which index 07ede39fd..c43704ae8 100644 --- a/Completion/Zsh/Command/_which +++ b/Completion/Zsh/Command/_which @@ -6,7 +6,8 @@ cargs=( \ '(-v -c)-w[print command type]' \ '-p[always do a path search]' \ '-m[treat the arguments as patterns]' \ - '-s[print symlink free path as well]' \ + '(-S)-s[print symlink free path as well]' \ + '(-s)-S[show steps in the resolution of symlinks]' \ '*:commands:->command' ) farg='-f[output contents of functions]' aarg='-a[print all occurrences in path]' diff --git a/Completion/Zsh/Command/_zattr b/Completion/Zsh/Command/_zattr index 1924bb28d..e48047f6c 100644 --- a/Completion/Zsh/Command/_zattr +++ b/Completion/Zsh/Command/_zattr @@ -1,7 +1,6 @@ #compdef zgetattr zsetattr zdelattr zlistattr -local state line expl ret=1 REPLY -local -a args privs +local context state line expl ret=1 REPLY case $service in zgetattr) @@ -29,6 +28,8 @@ _arguments \ esac && ret=0 if [[ $state = attrs ]]; then - zlistattr ${~${(Q)line[1]}} REPLY 2> /dev/null - _wanted attrs expl 'attribute' compadd $REPLY + zlistattr ${(Q)${~line[1]}} REPLY 2> /dev/null + _wanted -C "$context[1]" attrs expl 'attribute' compadd -a REPLY && ret=0 fi + +return ret diff --git a/Completion/Zsh/Command/_zle b/Completion/Zsh/Command/_zle index 2bfc708e5..3ed373348 100644 --- a/Completion/Zsh/Command/_zle +++ b/Completion/Zsh/Command/_zle @@ -13,20 +13,24 @@ compwids=(accept-and-menu-complete menu-expand-or-complete reverse-menu-complete) -opts=(-A -C -D -L -M -N -R -U -a -c -l \* :) +opts=(-A -C -D -F -L -M -N -R -T -U -a -c -l -r \* :) _arguments -s -S \ "($opts)-A[define widget alias]:old widget:->widget :new widget:->widget" \ "($opts)-C[define completion widget]:new widget name:->comp-widget :completion widget:->builtin-comp-widget :widget shell function:->function" \ "($opts)-D[delete widget]:*:widget:->widget" \ - \(${(j. .)opts:#-l}')-L[with -l, list as commands]' \ + \(${(j. .)opts:#-[lFT]}')-L[with -l, list as commands]' \ \(${(j. .)opts:#-[La]}')-l+[list user-defined widgets]:*:-:->listing' \ \(${(j. .)opts:#-l}')-a[with -l, list all widgets]' \ + "(: * ${(j. .)opts:#-[Lw]})-F[install file descriptor handler]:file descriptor:_file_descriptors::handler:_functions" \ + "!($opts)-K:keymap:compadd -a keymaps" \ "($opts)-M[display message]:message: " \ "($opts)-N[define new widget]:widget name:->widget-or-function ::widget shell function:->function" \ \(${(j. .)opts:#-c}')-R+[redisplay]:*:-:->redisplay' \ \(${(j. .)opts:#-R}')-c[with -R, clear listing]' \ "($opts)-U[unget to input stack]:string: " \ + '(: *)-T[manipulate transformations]:transformation:(tc):function:_functions' \ + \(${(j. .)opts:#-T}')-r[remove transformations]' \ '(-):widget:->widget' \ '(-)*::widget args:->args' && ret=0 diff --git a/Completion/Zsh/Command/_zmodload b/Completion/Zsh/Command/_zmodload index ffcab28dd..e144b981e 100644 --- a/Completion/Zsh/Command/_zmodload +++ b/Completion/Zsh/Command/_zmodload @@ -4,35 +4,38 @@ local suf comp state line expl curcontext="$curcontext" ret=1 NORMARG typeset -A opt_args suf=() -_arguments -n -C -A "-*" -s \ - '(-i -u -d -a -b -c -I -p -f -e)-A[create module aliases]' \ - '-u[unload module]' \ - '(-e)-a[autoload module]' \ - '(-c -I -p -f)-b[autoload module for builtins]' \ - '(-b -I -p -f)-c[autoload module for condition codes]' \ - '(-i)-d[list or specify module dependencies]' \ - '(-i -u -d -a -b -c -p -f -L -A)-e[test if modules are loaded]' \ - '(-b -c -I -p)-f[autoload module for math functions]' \ - '(-u -b -c -p -f -A)-F[handle features]' \ +_arguments -n -C -S -s \ + '(-R -P -i -u -d -a -b -c -I -p -f -e -F -m)-A[create module aliases]' \ + '(-)-R[remove module aliases]' \ + '(-A -R -F -L -m -P -l -e)-u[unload module]' \ + '(-d -e -l)-a[autoload module]' \ + '(-c -d -I -p -f -F -P -l -m -A -R)-b[autoload module for builtins]' \ + '(-b -d -I -p -f -F -P -l -m -A -R)-c[autoload module for condition codes]' \ + '(-A -R -F -I -P -a -b -c -e -f -i -l -m -p)-d[list or specify module dependencies]' \ + '(-i -u -d -a -b -c -p -f -L -R)-e[test if modules are loaded]' \ + '(-b -c -d -I -p -F -P -l -m -A -R)-f[autoload module for math functions]' \ + '(-u -b -c -d -p -f -A -R -I)-F[handle features]' \ + '(-u -b -c -d -p -f -A -R -I)-m[treat feature arguments as patterns]' \ '(-d -e)-i[suppress error if command would do nothing]' \ - '(-b -c -p -f)-I[define infix condition names]' \ - '(-u -b -c -p -f -A)-l[list features]' \ + '(-b -c -d -p -f -F -P -m)-I[define infix condition names]' \ + '(-u -b -c -d -p -f -A -R)-l[list features]' \ '(-e -u)-L[output in the form of calls to zmodload]' \ - '(-b -c -I -f)-p[autoload module for parameters]' \ - '(-u -b -c -p -f -A)-P[array param for features]:array name:_parameters' \ - '*:params:->params' && ret=0 + '(-b -c -d -I -f -F -P -l -m -A -R)-p[autoload module for parameters]' \ + '(-u -b -c -d -p -f -A -R)-P[array param for features]:array name:_parameters' \ + '(-)*:params:->params' && ret=0 [[ $state = params ]] || return ret -(( $+opt_args[-A] )) && compset -P '*=' || suf=( -S '=' ) - +if (( $+opt_args[-A] )); then + compset -S '=*' || compset -P '*=' || suf=( -S '=' ) +fi if (( $+opt_args[-F] && CURRENT > NORMARG )); then local module=$words[NORMARG] local -a features if [[ $modules[$module] != loaded ]]; then - _message "features for unloaded module" + _message -e features "feature for unloaded module" else zmodload -lFP features $module if compset -P -; then @@ -41,6 +44,9 @@ if (( $+opt_args[-F] && CURRENT > NORMARG )); then elif compset -P +; then # only disabled features needed features=(${${features:#+*}##?}) + else + # complete opposite of current feature state, + is default + features=(${${features#-}/(#s)+/-}) fi _wanted features expl feature compadd -a features fi diff --git a/Completion/Zsh/Command/_zstyle b/Completion/Zsh/Command/_zstyle index eb27117b2..9a6d61891 100644 --- a/Completion/Zsh/Command/_zstyle +++ b/Completion/Zsh/Command/_zstyle @@ -20,6 +20,9 @@ _completers() { compadd "$@" "$disp[@]" - "$us${^list[@]}" } +_vcs_info_hooks() { + compadd - ${functions[(I)+vi-*]#+vi-} +} # Assoc array of styles; the values give the possible top-level # contexts: # c completion @@ -122,6 +125,7 @@ styles=( select-prompt c: select-scroll c: separate-sections c:bool + show-ambiguity c: show-completer c:bool single-ignored c:single-ignored sort c:bool @@ -176,7 +180,10 @@ styles=( actionformats v:vcs-format branchformat v:branch-format nvcsformats v: + hgrevformat v:hgrev-format stgitformat v:stg-format + patch-format v:patch-format + nopatch-format v:patch-format max-exports v: enable v:vcs disable v:vcs @@ -190,7 +197,16 @@ styles=( use-server v:bool use-simple v:bool get-revision v:bool + get-mq v:bool + get-bookmarks v:bool + get-unapplied v:bool + debug v:bool + hooks v:_vcs_info_hooks use-prompt-escapes v:bool + use-quilt v:bool + quilt-standalone v:bool + quilt-patch-dir v:_directories + quiltcommand v:_command_names chpwd z:bool progress z:progress @@ -307,7 +323,7 @@ while (( $#state )); do (cmdorcont) _alternative -O suf \ - 'commands:command:_command ' \ + 'commands:command:_path_commands' \ 'contexts:context:(-array-value- -brace-parameter- -command- -condition- -math- -parameter- -redirect- -subscript- -value-)' ;; @@ -549,7 +565,18 @@ while (( $#state )); do compset -P '*%' _values -s '' 'format replacement' \ 'b[the current branch]' \ - 'r[current revision number]' \ + 'r[current revision number]' + else + _message -e formats 'vcs format' + fi + ;; + + (hgrev-format) + if [[ $PREFIX = *% ]]; then + compset -P '*%' + _values -s '' 'format replacement' \ + 'h[current revision hash (global)]' \ + 'r[current revision number (local)]' else _message -e formats 'vcs format' fi @@ -566,6 +593,22 @@ while (( $#state )); do fi ;; + (patch-format) + if [[ $PREFIX = *% ]]; then + compset -P '*%' + _values -s '' 'format replacement' \ + 'p[name of top-most patch (applied-string)]' \ + 'u[number of unapplied patches (unapplied-string)]' \ + 'n[number of applied patches]' \ + 'c[number of unapplied patches.]' \ + 'a[number of all patches]' \ + 'g[names of active mq guards (hg backend)]' \ + 'G[number of active mq guards (hg backend)]' + else + _message -e formats 'vcs format' + fi + ;; + (_*) ${=state[1]} $suf ;; diff --git a/Completion/Zsh/Context/_brace_parameter b/Completion/Zsh/Context/_brace_parameter index 2aeb12bf4..fcca4bf84 100644 --- a/Completion/Zsh/Context/_brace_parameter +++ b/Completion/Zsh/Context/_brace_parameter @@ -104,9 +104,9 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then done if [[ -z $found_percent ]]; then - flags=("%:Expand prompt sequences") + flags=("%:expand prompt sequences") else - flags=("%:Expand prompts respecting options") + flags=("%:expand prompts respecting options") fi case $q_last in (0) @@ -134,58 +134,74 @@ if [[ $PREFIX = *'${('[^\)]# ]]; then flags+=("Q:remove one level of quoting") fi if [[ -z $found_m ]]; then - flags+=("m:Count multibyte width in padding calculation") + flags+=("m:count multibyte width in padding calculation") else - flags+=("m:Count number of character code points in padding calculation") + flags+=("m:count number of character code points in padding calculation") fi flags+=( - "#:Evaluate as numeric expression" - "@:Double-quoted splitting of scalars" - "A:Create array parameter" - "a:Sort in array index order (with O to reverse)" - "c:Count characters in an array (with \${(c)#...})" - "C:Capitalize words" - "D:Perform directory name abbreviation" - "e:Perform single-word shell expansions" - "f:Split the result on newlines" - "F:Join arrays with newlines" - "g:Process echo array sequences (needs options)" - "i:Sort case-insensitively" - "k:Subsitute keys of associative arrays" - "L:Lower case all letters" - "n:Sort decimal integers numerically" - "o:Sort in ascending order (lexically if no other sort option)" - "O:Sort in descending order (lexically if no other sort option)" - "P:Use parameter value as name of parameter for redirected lookup" - "t:Substitute type of parameter" - "u:Substitute first occurrence of each unique word" - "U:Upper case all letters" - "v:Substitute values of associative arrays (with (k))" - "V:Visibility enhancements for special characters" - "w:Count words in array or string (with \${(w)#...})" - "W:Count words including empty words (with \${(W)#...})" - "X:Report parsing errors and eXit substitution" - "z:Split words as if zsh command line" - "0:Split words on null bytes" - "p:Handle print escapes in parameter flag arguments" - "~:Treat strings in parameter flag arguments as patterns" - "j:Join arrays with specified string" - "l:Left-pad resulting words" - "r:Right-pad resulting words" - "s:Split words on specified string" - "Z:Split words as if zsh command line (with options)" - # "_:Extended flags, for future expansion" - "S:Search substrings in #, %, / expressions" - "I:Search <argument>th match in #, %, / expressions" - "B:Include index of beginning of match in #, %, / expressions" - "E:Include index of end of match in #, %, / expressions" - "M:Include matched portion in #, %, / expressions" - "N:Include length of match in #, %, expressions" - "R:Include rest (unmatched portion) in #, %, / expressions" + "#:evaluate as numeric expression" + "@:double-quoted splitting of scalars" + "A:create array parameter" + "a:sort in array index order (with O to reverse)" + "c:count characters in an array (with \${(c)#...})" + "C:capitalize words" + "D:perform directory name abbreviation" + "e:perform single-word shell expansions" + "f:split the result on newlines" + "F:join arrays with newlines" + "g:process echo array sequences (needs options)" + "i:sort case-insensitively" + "k:subsitute keys of associative arrays" + "L:lower case all letters" + "n:sort decimal integers numerically" + "o:sort in ascending order (lexically if no other sort option)" + "O:sort in descending order (lexically if no other sort option)" + "P:use parameter value as name of parameter for redirected lookup" + "t:substitute type of parameter" + "u:substitute first occurrence of each unique word" + "U:upper case all letters" + "v:substitute values of associative arrays (with (k))" + "V:visibility enhancements for special characters" + "w:count words in array or string (with \${(w)#...})" + "W:count words including empty words (with \${(W)#...})" + "X:report parsing errors and eXit substitution" + "z:split words as if zsh command line" + "0:split words on null bytes" + "p:handle print escapes or variables in parameter flag arguments" + "~:treat strings in parameter flag arguments as patterns" + "j:join arrays with specified string" + "l:left-pad resulting words" + "r:right-pad resulting words" + "s:split words on specified string" + "Z:split words as if zsh command line (with options)" + # "_:extended flags, for future expansion" + "S:search substrings in #, %, / expressions" + "I:search <argument>th match in #, %, / expressions" + "B:include index of beginning of match in #, %, / expressions" + "E:include index of end of match in #, %, / expressions" + "M:include matched portion in #, %, / expressions" + "N:include length of match in #, % expressions" + "R:include rest (unmatched portion) in #, %, / expressions" ) _describe -t flags "parameter flag" flags -Q -S '' return +elif compset -P '*:([\|\*\^]|\^\^)'; then + _arrays + return elif compset -P '*:'; then + flags=( + '-:substitute alternate value if parameter is null' + '+:susbtitute alternate value if parameter is non-null' + '=:substitute and assign alternate value if parameter is null' + '\:=:unconditionally assign value to parameter' + '?:print error if parameter is set and non-null' + '#:filter value matching pattern' + '|:set difference' + '*:set intersection' + '^:zip arrays' + '^^:zip arrays reusing values from shorter array' + ) + _describe -t flags "operator" flags -Q -S '' _history_modifiers p return fi diff --git a/Completion/Zsh/Context/_subscript b/Completion/Zsh/Context/_subscript index cf1ec49a4..0ccc0c4ef 100644 --- a/Completion/Zsh/Context/_subscript +++ b/Completion/Zsh/Context/_subscript @@ -23,7 +23,7 @@ if [[ $BUFFER[1,pos-1] = (|*[[:space:]:=]##)\~\[ ]]; then elif [[ "$PREFIX" = :* ]]; then _wanted characters expl 'character class' \ compadd -p: -S ':]' alnum alpha ascii blank cntrl digit graph \ - lower print punct space upper xdigit + lower print punct space upper xdigit IFS IDENT IFSSPACE WORD elif compset -P '\('; then local match compset -S '\)*' diff --git a/Completion/Zsh/Function/_add-zsh-hook b/Completion/Zsh/Function/_add-zsh-hook new file mode 100644 index 000000000..c70a4976f --- /dev/null +++ b/Completion/Zsh/Function/_add-zsh-hook @@ -0,0 +1,24 @@ +#compdef add-zsh-hook + +local context state state_descr line +typeset -A opt_args + +_add-zsh-hook_hooks() { + if (( $+opt_args[-d] )); then + _wanted functions expl "installed hooks" compadd -a - "$line[1]_functions" && return 0 + else + _functions && return 0 + fi + return 1 +} + +_add-zsh-hook() { + _arguments -s -w -S : \ + '(-D)-d[remove HOOK from the array]' \ + '(-d)-D[interpret HOOK as pattern to remove from the array]' \ + {-U,-z,-k}"[passed to 'autoload']" \ + ':hook class:(chpwd precmd preexec periodic zshaddhistory zshexit zsh_directory_name)' \ + ':hook function:_add-zsh-hook_hooks' +} + +_add-zsh-hook "$@" diff --git a/Completion/Zsh/Function/_zcalc b/Completion/Zsh/Function/_zcalc new file mode 100644 index 000000000..093a7a91d --- /dev/null +++ b/Completion/Zsh/Function/_zcalc @@ -0,0 +1,7 @@ +#compdef zcalc + +_arguments -s -w -S : \ + '-#[specify default base]:base: ' \ + '-f[force floating point for all expressions]' \ + '-e[treat command line as expressions to be output immediately]' \ + '*:expression: ' diff --git a/Completion/Zsh/Type/_globflags b/Completion/Zsh/Type/_globflags index ca665466b..5833dc8f1 100644 --- a/Completion/Zsh/Type/_globflags +++ b/Completion/Zsh/Type/_globflags @@ -4,11 +4,17 @@ local ret=1 local -a flags if compset -P a; then - _message -e numbers 'errors' + _message -e number 'errors' return elif compset -P q; then _globquals return +elif compset -P 'c[0-9]##,'; then + _message -e number 'max repetitions' + return +elif compset -P c; then + _message -e number 'repetitions (min or exact)' + return fi flags=( @@ -17,6 +23,8 @@ flags=( 'I:case sensitive matching' 's:match start of string' 'e:match end of string' + 'U:consider all characters to be one byte' + 'u:support multibyte characters in pattern' ) [[ $compstate[context] = condition ]] && flags+=( 'b:activate backreferences' @@ -29,6 +37,7 @@ _describe -t globflags "glob flag" flags -Q -S ')' && ret=0 flags=( 'a:approximate matching' 'q:introduce glob qualifier' + 'c:match repetitions of preceding pattern' ) _describe -t globflags "glob flag" flags -Q -S '' && ret=0 diff --git a/Completion/Zsh/Type/_globquals b/Completion/Zsh/Type/_globquals index 37db161d0..042b27400 100644 --- a/Completion/Zsh/Type/_globquals +++ b/Completion/Zsh/Type/_globquals @@ -213,7 +213,7 @@ case $state in ".:plain files" "@:symbolic links" "=:sockets" - "p:name pipes (FIFOS)" + "p:named pipes (FIFOs)" "*:executable plain files" "%:device files" "r:owner-readable" diff --git a/Completion/Zsh/Type/_history_modifiers b/Completion/Zsh/Type/_history_modifiers index f8dcd45ae..658f9f346 100644 --- a/Completion/Zsh/Type/_history_modifiers +++ b/Completion/Zsh/Type/_history_modifiers @@ -66,6 +66,7 @@ while true; do list+=( "a:absolute path" "A:absolute path resolving symbolic links" + "c:PATH search for command" "g:globally apply s or &" "h:head - strip trailing path element" "t:tail - strip directories" diff --git a/Completion/compaudit b/Completion/compaudit index 00125e4db..fb0463ca5 100644 --- a/Completion/compaudit +++ b/Completion/compaudit @@ -71,6 +71,7 @@ if [[ -n $_compdir ]]; then _i_addfiles=(${_compdir}/*(/^M)) fi for _i_line in {1..$#_i_addfiles}; do + (( $_i_line )) || break _i_file=${_i_addfiles[$_i_line]} [[ -d $_i_file && -z ${fpath[(r)$_i_file]} ]] || _i_addfiles[$_i_line]= diff --git a/Completion/compinit b/Completion/compinit index f9d2c574c..9470c92f6 100644 --- a/Completion/compinit +++ b/Completion/compinit @@ -105,17 +105,17 @@ done # The associative arrays containing the definitions for the commands and # services. -typeset -gA _comps _services _patcomps _postpatcomps +typeset -gHA _comps _services _patcomps _postpatcomps # `_compautos' contains the names and options for autoloaded functions # that get options. -typeset -gA _compautos +typeset -gHA _compautos # The associative array use to report information about the last # completion to the outside. -typeset -gA _lastcomp +typeset -gHA _lastcomp # Remember dumpfile. if [[ -n $_i_dumpfile ]]; then @@ -127,12 +127,13 @@ fi # The standard options set in completion functions. -typeset -ga _comp_options +typeset -gHa _comp_options _comp_options=( bareglobqual extendedglob glob multibyte + multifuncdef nullglob rcexpandparam unset @@ -161,7 +162,7 @@ _comp_options=( # have a valid stdin descriptor (zle closes it before calling widgets) # and don't get confused by user's ZERR trap handlers. -typeset -g _comp_setup='local -A _comp_caller_options; +typeset -gH _comp_setup='local -A _comp_caller_options; _comp_caller_options=(${(kv)options[@]}); setopt localoptions localtraps localpatterns ${_comp_options[@]}; local IFS=$'\'\ \\t\\r\\n\\0\'' diff --git a/Completion/compinstall b/Completion/compinstall index c04543c57..afa517edb 100644 --- a/Completion/compinstall +++ b/Completion/compinstall @@ -3,6 +3,8 @@ emulate -L zsh setopt extendedglob +zmodload -F zsh/files b:zf_ln || return 1 + local key local compcontext=-default- @@ -1958,11 +1960,14 @@ if [[ -z $ifile || -d $ifile ]] || fi local tmpout=${TMPPREFIX:-/tmp/zsh}compinstall$$ +zf_ln -fn =(<<<'') $tmpout && # safe tempfile creation +zf_ln -fn =(<<<'') ${tmpout}x || return 1 + # # Assemble the complete set of lines to # insert. # -__ci_output >$tmpout +__ci_output >>$tmpout if [[ -n $ifile ]]; then if [[ $ifile != *(zshrc|zlogin|zshenv) ]]; then @@ -1984,15 +1989,15 @@ future use." fi if { { grep "$endline" $ifile >/dev/null 2>&1 && sed -e "/^[ ]*$endline/r $tmpout -/^[ ]*$startline/,/^[ ]*$endline/d" $ifile >${tmpout}2 } || - { cp $ifile ${tmpout}2 && cat $tmpout >>${tmpout}2 } } && - cp ${tmpout}2 $ifile && rm -f ${tmpout}2; then +/^[ ]*$startline/,/^[ ]*$endline/d" $ifile >>${tmpout}x } || + { cp $ifile ${tmpout}x && cat $tmpout >>${tmpout}x } } && + cp ${tmpout}x $ifile && rm -f ${tmpout}x; then print "\nSuccessfully added compinstall lines to $ifile." rm -f $tmpout else print "\nFailure adding lines to $ifile. Lines left in \`$tmpout'" fi - rm -f ${tmpout}2 + rm -f ${tmpout}x elif read -q key'?Print them to stdout instead ([y]es, [n]o)? '; then cat $tmpout rm -f $tmpout diff --git a/Completion/openSUSE/Command/_SUSEconfig b/Completion/openSUSE/Command/_SUSEconfig index d50828529..737a80b17 100644 --- a/Completion/openSUSE/Command/_SUSEconfig +++ b/Completion/openSUSE/Command/_SUSEconfig @@ -1,15 +1,7 @@ #compdef SuSEconfig -local curcontext="$curcontext" state line -typeset -A opt_args - -if [[ -z "$_SuSEconfig_modules" ]]; then - for i in /sbin/conf.d/SuSEconfig.*; do - case $i in *.rpm*|*.swap|*.bak|*.orig|*~|\#*) continue;; esac - _SuSEconfig_modules=($_SuSEconfig_modules ${i##*/SuSEconfig.}) - done -fi - +local modules +modules=( /sbin/conf.d/SuSEconfig.*~(*.rpm*|*.swap|*.bak|*.orig|*~|\#*)(N:e) ) _arguments \ '--help' \ @@ -17,12 +9,6 @@ _arguments \ '--force' \ '--verbose' \ '--nonewpackage' \ - '--module:module:->module' && return 0 - -case $state in - module) compadd $_SuSEconfig_modules ;; -esac - -# Usage: SuSEconfig [--quick|--nonewpackage|--force|--verbose] [--module name] - - + '-norestarts' \ + '-nomodule' \ + '--module:module:compadd -a modules' diff --git a/Completion/Linux/Command/_yast b/Completion/openSUSE/Command/_yast index f008b404f..98585f068 100644 --- a/Completion/Linux/Command/_yast +++ b/Completion/openSUSE/Command/_yast @@ -3,9 +3,12 @@ _arguments \ '(- 1)'{-h,--help}'[display help information]' \ '(- 1)'{-l,--list}'[list all available modules]' \ - '(-g --geometry)'{-g,--geometry}'[specify default window size]:_x_geometry' \ - '(-s --style)'{-s,--style}'[specify widget style]:style:(qt)' \ + '(-g --geometry --ncurses)'{-g,--geometry}'[specify default window size]:_x_geometry' \ + '--qt[use the QT graphical frontend]' \ + '--gtk[use the GTK graphical frontend]' \ + '--ncurses[use the curses text-mode frontend]' \ '--noborder[no window manager border for main window]' \ '--fullscreen[use full screen]' \ '(-)'{-i,--install}'[install package]:*:package file:_files -g "*.rpm(-.)"' \ + '(-)--remove[remove package]:*:package' \ '1:module:( ${${(f)"$($words[1] -l 2>/dev/null)"}[2,-1]##* } )' diff --git a/Completion/openSUSE/Command/_yast2 b/Completion/openSUSE/Command/_yast2 deleted file mode 100644 index b9c7f2489..000000000 --- a/Completion/openSUSE/Command/_yast2 +++ /dev/null @@ -1,30 +0,0 @@ -#compdef yast2 yast - -local curcontext="$curcontext" state line -typeset -A opt_args - -if [[ -z "$_yast2_modules" ]]; then - for i in $(/sbin/yast2 --list | grep -v "Available.*modules"); do - _yast2_modules=($_yast2_modules $i) - done -fi - -_arguments -s \ - '(--list)-l[list all available modules]' '(-l)--list' \ - '(--help)-h[help]' '(-h)--help'\ - \ - {'(--geometry)-g[default window size (qt only)]','(-g)--geometry'}':geometry:(800x600+0+0)' \ - '(--style)-s[widget style (qt only)]' '(-s)--style' \ - \ - {'(--install)-i[install rpm package]','(-i)--install'}':filename:_files' \ - \ - '--noborder[no window manager border for main window]' '--noborder' \ - '--fullscreen[use full screen]' '--fullscreen' \ - \ - ':module:->module' && return 0 - -case $state in - module) compadd $_yast2_modules; _files -g "*.ycp";; -esac - - |