diff options
Diffstat (limited to 'Completion')
24 files changed, 397 insertions, 292 deletions
diff --git a/Completion/BSD/Command/_cu b/Completion/BSD/Command/_cu new file mode 100644 index 000000000..bdd579519 --- /dev/null +++ b/Completion/BSD/Command/_cu @@ -0,0 +1,7 @@ +#compdef cu + +_arguments -s -A '-*' \ + '-d[do not block waiting for a carrier to be detected]' \ + '-l[line to use]:line:(/dev/(cuaU#<->|ttyS<->)(N%c))' \ + '-s[line speed]:line speed:(75 110 300 1200 2400 4800 9600 19200 38400 57600 115200)' \ + '(-*)1:host:' diff --git a/Completion/BSD/Command/_fw_update b/Completion/BSD/Command/_fw_update new file mode 100644 index 000000000..b01749f3f --- /dev/null +++ b/Completion/BSD/Command/_fw_update @@ -0,0 +1,10 @@ +#compdef fw_update + +_arguments -s -S -A "-*" \ + '(*)-a[install or update firmware for all drivers]' \ + '-d[delete drivers instead of adding them]' \ + '-i[display information]' \ + '-n[dry run]' \ + '-p[use the firmware at specified path]:path:' \ + '*-v[verbose output]' \ + '(-a)*:driver:' diff --git a/Completion/BSD/Command/_rcctl b/Completion/BSD/Command/_rcctl new file mode 100644 index 000000000..0a030f486 --- /dev/null +++ b/Completion/BSD/Command/_rcctl @@ -0,0 +1,42 @@ +#compdef rcctl + +local context state line +local -a actions subcmds variables + +actions=(check reload restart start stop) +subcmds=(disable enable get getdef ls order set) +variables=(class flags status timeout user) + +if [[ $service == "rcctl" ]]; then + _arguments -C \ + '-d[print debug information]' \ + '-f[forcibly start the daemon]' \ + ':subcommand:('"$actions ${${${+words[(r)-[df]]}#1}/0/$subcmds}"\) \ + '*:: :->subcmd' && return + service="$words[1]" +fi + +case $service in + get|getdef) + _arguments \ + ':service:_services' \ + ':variable:compadd -a variables' + ;; + ls) + _arguments ':display a list of services and daemons matching:(all faulty off on started stopped)' + ;; + order) + _arguments \ + ':service to start first:_services' + '*:service to start next:_services' + ;; + set) + _arguments \ + ':service:_services' \ + ':variable:compadd -a variables' \ + '*:argument:' + ;; + ${(~j:|:)actions}|disable|enable) + _arguments "*:service to $words[2]:_services" + ;; +esac diff --git a/Completion/Debian/Command/_apt b/Completion/Debian/Command/_apt index db4ceef10..0bc20c6df 100644 --- a/Completion/Debian/Command/_apt +++ b/Completion/Debian/Command/_apt @@ -407,10 +407,12 @@ _apt-cmd () { /$'install\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" avail' \# \ /$'[^\0/]#/'/ /$'[^\0/]#\0'/ ':release name::_apt_releases' \) \| \ /$'remove\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ + /$'purge\0'/ /$'[^\0]#\0'/ ':packages::_deb_packages "$expl_packages[@]" installed' \# \| \ /$'upgrade\0'/ \| \ + /$'autoremove\0'/ \| \ /$'full-upgrade\0'/ \| \ /$'edit-sources\0'/ \| \ - /"[]"/ ':argument-1::compadd "$expl_action[@]" list search show update install remove upgrade full-upgrade edit-sources' + /"[]"/ ':argument-1::compadd "$expl_action[@]" list search show update install remove upgrade full-upgrade edit-sources autoremove purge' _apt-cmd () { local expl_action expl_packages diff --git a/Completion/Debian/Command/_aptitude b/Completion/Debian/Command/_aptitude index 2cb211149..b2b54599f 100644 --- a/Completion/Debian/Command/_aptitude +++ b/Completion/Debian/Command/_aptitude @@ -80,7 +80,7 @@ _arguments -C \ case $state in cmds) - cmds=( ${${(M)${(f)"$(LC_ALL=C _call_program commands aptitude -h 2>/dev/null)"}:#* - *}/(#b) (*[^ ]) #- (*)/$match[1]:$match[2]:l}) + cmds=( ${${(M)${(f)"$(LC_ALL=C _call_program commands aptitude -h 2>/dev/null)"}:# [^- ][^ ]## *}/(#b) ([^ ]##) ##(- )#([^- ]*)/$match[1]:$match[3]:l}) _describe -t commands 'aptitude command' cmds && ret=0 ;; diff --git a/Completion/Redhat/Command/_dnf b/Completion/Redhat/Command/_dnf index 297c95ae9..35b5aa27b 100644 --- a/Completion/Redhat/Command/_dnf +++ b/Completion/Redhat/Command/_dnf @@ -1,278 +1,198 @@ -#compdef dnf +#compdef dnf dnf-2 dnf-3 -# Main dispatcher -_dnf() { - _arguments -s \ - '(- *)'{-h,--help}'[show the help message]' \ - '(-t --tolerant)'{-t,--tolerant}'[be tolerant of errors]' \ - '(-C --cacheonly)'{-C,--cacheonly}'[run entirely from cache]' \ - '(-c --config)'{-c,--config=}'[config file location]:config file:_files' \ - '(-R --randomwait)'{-R,--randomwait=}'[maximum command wait time (in minutes)]:max wait time' \ - '(-d --debuglevel)'{-d,--debuglevel=}'[debug level (0-10)]:debug level' \ - '(-e --errorlevel)'{-e,--errorlevel=}'[error level (0-10)]:error level' \ - '(-y --assumeyes)'{-y,--assumeyes}'[answer yes for all questions]' \ - '--installroot=[set install root]:install root:_files -/' \ - '*--enablerepo=[enable or or more repositories]:repos to enable:_dnf_disabled_repos_list' \ - '*--disablerepo=[disable one or more repositories]:disable repos:_dnf_enabled_repos_list' \ - {*-x,*--exclude=}'[exclude package(s) by name or glob]:exclude packages' \ - '--version[show dnf version]' \ - '--obsoletes[enable obsoletes processing during updates]' \ - '--nogpgcheck[disable gpg signature checking]' \ - '--noplugins[disable dnf plugins]' \ - '--disablepresto[disable Presto plugin and don''''t download any deltarpms]' \ - '*::dnf command:_dnf_command' -} - -(( $+functions[_dnf_command] )) || _dnf_command() { - local -a _dnf_cmds - _dnf_cmds=( - "install:install the latest version of a package or group of packages" - "erase:remove an installed package (with its dependencies)" - "remove:remove an installed package (with its dependencies)" - "clean:clean local dnf cache" - "check-update:check if any updates are available" - "info:get description of available packages" - "list:is used to list various information about packages" - "groupinfo:get info on package groups" - "groupinstall:install a package group or groups" - "groupremove:remove a package group or groups" - "grouplist:list package groups" - "groupupdate:update a package group or groups" - "localinstall:install packages with local rpm files" - "localupdate:update packages with local rpm files" - "makecache:makes a local dnf cache" - "provides:find out which package provides some feature or file" - "whatprovides:find out which package provides some feature or file" - "search:find any packages matching pattern" - "shell:enter the 'dnf shell'" - "update:update one or more packages" - "upgrade:upgrade one or more packages" - ) - - if (( CURRENT == 1 )); then - _describe -t commands 'dnf command' _dnf_cmds || compadd "$@" - else - local curcontext="$curcontext" - - cmd="${${_dnf_cmds[(r)$words[1]:*]%%:*}}" - # Deal with any aliases - case $cmd in - remove) cmd="erase";; - whatprovides) cmd="provides";; - upgrade) cmd="update";; - esac - - if (( $#cmd )); then - curcontext="${curcontext%:*:*}:dnf-${cmd}:" - - local update_policy - zstyle -s ":completion:${curcontext}:" cache-policy update_policy - if [[ -z "$update_policy" ]]; then - zstyle ":completion:${curcontext}:" cache-policy _dnf_caching_policy - fi - - _call_function ret _dnf_$cmd || _message 'no more arguments' - else - _message "unknown dnf command: $words[1]" - fi - return ret - fi +_dnf_helper() { + compadd $($python_exec $helper "$@" -d 0 -q -C 2>/dev/null) } -# Fills the all pkg cache -_dnf_all_pkgs() { - if ( [[ ${+_all_pkgs} -eq 0 ]] || _cache_invalid ALL ) && - ! _retrieve_cache ALL; - then - _all_pkgs=( $(dnf -C list all | sed 's/\s.*//' | grep '\.' 2>/dev/null) ) - _store_cache ALL _all_pkgs - fi +_dnf_query_db() { + sqlite3 -batch -init /dev/null "$cache_file" "$1" } -# Fills the installed pkg cache -_dnf_installed_pkgs() { - if ( [[ ${+_installed_pkgs} -eq 0 ]] || _cache_invalid INSTALLED ) && - ! _retrieve_cache INSTALLED; - then - _installed_pkgs=( $(dnf -C list installed | sed 's/\s.*//' | grep '\.' 2>/dev/null) ) - _store_cache INSTALLED _installed_pkgs - fi +_dnf_disabled_repos() { + _dnf_helper repolist disabled "" } -# Fills the available pkg cache -_dnf_available_pkgs() { - if ( [[ ${+_available_pkgs} -eq 0 ]] || _cache_invalid AVAILABLE ) && - ! _retrieve_cache AVAILABLE; - then - _available_pkgs=( $(dnf -C list available | sed 's/\s.*//' | grep '\.' 2>/dev/null) ) - _store_cache AVAILABLE _available_pkgs - fi +_dnf_enabled_repos() { + _dnf_helper repolist enabled "" } -# Fills the upgrade pkg cache -_dnf_upgrade_pkgs() -{ - if ( [[ ${+_upgrade_pkgs} -eq 0 ]] || _cache_invalid UPGRADE ) && - ! _retrieve_cache UPGRADE; - then - _upgrade_pkgs=( $(dnf -C list upgrade | sed 's/\s.*//' | grep '\.' 2>/dev/null) ) - _store_cache UPGRADE _upgrade_pkgs +_dnf_available_packages() { + if [ -r $cache_file ]; then + compadd $(_dnf_query_db "select pkg from available WHERE pkg LIKE \"$1%\"") + else + _dnf_helper install "$1" fi } -# Gets the list of defined repos -__dnf_repos() { - local trepo - local -a tarray - tarray=( $(egrep -h '(^\[.*\]|^enabled.*=)' /etc/dnf.repos.d/*.repo /etc/dnf.conf 2>/dev/null | sed -e 's/ //g' | sed -e 's/\[//g' | sed -e 's/\].*$//g' 2>/dev/null) ) - local -i eindex=0 - local -i dindex=0 - for line in $tarray; do - if [[ "$line" = "enabled=1" ]]; then - enabled_dnf_repos+=($trepo) - elif [[ "$line" = "enabled=0" ]]; then - disabled_dnf_repos+=($trepo) - elif [[ "$line" != "main" ]]; then - trepo=$line - fi - done -} - -(( $+functions[_dnf_disabled_repos_list] )) || _dnf_disabled_repos_list() { - local -a enabled_dnf_repos disabled_dnf_repos - __dnf_repos - _sequence compadd "$@" - -a disabled_dnf_repos -} - -(( $+functions[_dnf_enabled_repos_list] )) || _dnf_enabled_repos_list() { - local -a enabled_dnf_repos disabled_dnf_repos - __dnf_repos - _sequence compadd "$@" - -a enabled_dnf_repos -} - -# Completion function for erase|remove -(( $+functions[_dnf_erase] )) || _dnf_erase() { - _dnf_installed_pkgs - compadd "$@" -a -- _installed_pkgs -} - -# Completion function for install -(( $+functions[_dnf_install] )) || _dnf_install() { - if ! [[ $PREFIX == */* ]]; then - _dnf_available_pkgs +_dnf_installed_packages() { + if [ -r $cache_file ]; then + compadd $(_dnf_query_db "select pkg from installed WHERE pkg LIKE \"$1%\"") + else + _dnf_helper remove "$1" fi - - local ret=1 - _tags files packages - while _tags; do - if _requested files; then - compadd "$@" -a -- _available_pkgs - fi - if _requested packages; then - _call_function - _dnf_localinstall - fi - (( ret )) || break - done - return ret } -# Completion function for localinstall -(( $+functions[_dnf_localinstall] )) || _dnf_localinstall() { +_dnf_local_packages() { _files -/ -g '(#i)*.rpm(-.)' } -# Completion function for localupdate -(( $+functions[_dnf_localupdate] )) || _dnf_localupdate() { - _files -/ -g '(#i)*.rpm(-.)' -} - -# Completion function for update/upgrade -(( $+functions[_dnf_update] )) || _dnf_update() { - _dnf_upgrade_pkgs - compadd "$@" -a -- _upgrade_pkgs -} - -_dnf_all() { - _dnf_all_pkgs - compadd "$@" -a -- _all_pkgs -} - -_dnf_list_or_info() { - local -a listlist - listlist=( - "all:all packages in repositories" - "available:packages available in repositories" - "updates:packages with updates available" - "installed:installed packages" - "extras:packages installed that are not available in any dnf repository" - "obsoletes:packages installed that are obsoleted" - "recent:packages recently added to repositories" - ) - - if (( CURRENT == 2 )); then - _describe -t dnf-list-subcmds "dnf info/list sub-commands" listlist || _dnf_all +_dnf() { + if [[ "$(readlink /usr/bin/dnf)" == "dnf-2" ]]; then + local python_exec="python2" else - local subcmd - subcmd="${${listlist[(r)$words[2]:*]%%:*}}" - # offer packages selected by the subcommand - case $subcmd in - all) _dnf_all;; - installed) _dnf_erase;; - available) _dnf_install;; - updates) _dnf_update;; - esac + local python_exec="python3" fi -} - -# Completion function for list -(( $+functions[_dnf_list] )) || _dnf_list() { - _dnf_list_or_info -} - -# Completion function for info -(( $+functions[_dnf_info] )) || _dnf_info() { - _dnf_list_or_info -} + local helper=$(${python_exec} -c "import dnf.cli; print('{}/completion_helper.py'.format(dnf.cli.__path__[0]))") + local cache_file="/var/cache/dnf/packages.db" -# Completion function for provides|whatprovides -(( $+functions[_dnf_provides] )) || _dnf_provides() { - _files + _arguments -s \ + '(- *)'{-h,--help}'[show the help message]' \ + '--version[show dnf version]' \ + '(-v --verbose)'{-v,--verbose}'[set verbose, show debug messages]' \ + '(-q --quiet)'{-q,--quiet}'[show just the relevant content]' \ + '--allowerasing[allow erasing of installed packages]' \ + '(-y --assumeyes)'{-y,--assumeyes}'[answer yes for all questions]' \ + '(-C --cacheonly)'{-C,--cacheonly}'[run entirely from cache]' \ + '(-c --config)'{-c,--config=}'[config file location]:config file:_files' \ + '(-R --randomwait)'{-R,--randomwait=}'[maximum command wait time (in minutes)]:max wait time' \ + '--releasever=[configure DNF for another release]:release' \ + '--refresh[set metadata as expired before running the command]' \ + '--nogpgcheck[skip checking GPG signatures on package]' \ + '--installroot=[set install root]:install root:_files -/' \ + '*--enablerepo=[enable one or more repositories]:repos to enable:_dnf_disabled_repos' \ + '*--disablerepo=[disable one or more repositories]:disable repos:_dnf_enabled_repos' \ + '*::dnf command:_dnf_command' } -# Completion function for clean -(( $+functions[_dnf_clean] )) || _dnf_clean() { - local -a cleanlist - cleanlist=( - "all:all cache" - "cache:all cache" - "dbcache:DB cache" - "headers:cache headers" - "packages:cache packages" - "metadata:cache meta-data" +_dnf_command() { + local -a _dnf_cmds + _dnf_cmds=( + "autoremove:automatically remove no longer required packages" + "check-update:check for available package upgrades" + "clean:remove cached data" + "distro-sync:synchronize installed packages to the latest available versions" + "downgrade:downgrade a package" + "erase:deprecated alias for remove" + "group:display, or use, the groups information" + "help:display a helpful usage message" + "history:display, or use, the transaction history" + "info:display details about a package or group of packages" + "install:install a package or packages on your system" + "list:list a package or groups of packages" + "makecache:generate the metadata cache" + "mark:mark or unmark installed packages as installed by user" + "provides:find what package provides the given value" + "reinstall:reinstall a package" + "remove:remove a package or packages from your system" + "repolist:display the configured software repositories" + "repository-packages:run commands on top of all packages in given repository" + "search:search package details for the given string" + "update:deprecated alias for upgrade" + "updateinfo:display advisories about packages" + "upgrade:upgrade a package or packages on your system" + "upgrade-to:upgrade a package on your system to the specified version" ) - if (( CURRENT == 2 )); then - _describe -t dnf-clean-subcmds "dnf clean sub-commands" cleanlist - fi -} - -_dnf_caching_policy() { - local _dnfrepomds - local -a oldp - - # rebuild if cache is more than a week old - oldp=( "$1"(mw+1) ) - (( $#oldp )) && return 0 - - _dnfrepomds=( /var/cache/dnf/**/repomd.xml ) + if (( CURRENT == 1 )); then + _describe -t commands 'dnf command' _dnf_cmds || compadd "$@" + else + local command="${${_dnf_cmds[(r)$words[1]:*]%%:*}}" + # Deal with any aliases + case $command in + erase) command="remove";; + whatprovides) command="provides";; + update) command="upgrade";; + esac - if (( $#_dnfrepomds )); then - for repo in $_dnfrepomds; do - [[ "$repo" -nt "$1" ]] && return 0 - done + _is_path() { + [[ "$1" == *\/* ]] || [[ "$1" == \~* ]] + } + + local cur=$words[CURRENT] + local prev="" + [[ $CURRENT > 2 ]] && prev=$words[$((CURRENT - 1))] + + case $command in + install|upgrade|reinstall|info|check-update|distro-sync) + if ! _is_path "$cur"; then + _dnf_available_packages "$cur" + else + _dnf_local_packages + fi + ;; + remove|downgrade) + if ! _is_path "$cur"; then + _dnf_installed_packages "$cur" + elif [[ "$command" == downgrade ]]; then + _dnf_local_packages + fi + ;; + list|clean) + _dnf_helper $command "$prev" "$cur" + ;; + group) + local -a _dnf_group_cmds + _dnf_group_cmds=( + "summary:display groups overview" + "info:display package lists of a group" + "install:install packages from a group" + "list:list all matching groups" + "remove:mark the group removed" + "upgrade:upgrades the group and its packages" + "mark:mark a group for installation or removal" + ) + if (( CURRENT == 2 )); then + _describe -t commands 'dnf group command' _dnf_group_cmds + fi + ;; + help) + if (( CURRENT == 2 )); then + _dnf_helper '_cmds' '' + fi + ;; + history) + local -a _dnf_history_cmds + _dnf_history_cmds=( + "list:list transactions" + "info:describe the given transactions" + "redo:repeat the specified transaction" + "rollback:undo all since the given transaction" + "undo:undo transactions" + "userinstalled:list names of all packages installed by a user" + ) + if (( CURRENT == 2 )); then + _describe -t commands 'dnf history command' _dnf_history_cmds + else + _dnf_helper $command "$prev" "$cur" + fi + ;; + makecache) + if (( CURRENT == 2 )); then + _values 'make cache' 'timer' + fi + ;; + mark) + if (( CURRENT == 2 )); then + _values 'mark' 'install' 'remove' + else + _dnf_installed_packages "$cur" + fi + ;; + provides) + _files + ;; + repolist) + if (( CURRENT == 2 )); then + _values 'repolist' 'enabled' 'disabled' 'all' + fi + ;; + search) + if (( CURRENT == 2 )); then + _values 'search' 'all' + fi + ;; + esac fi - - return 1 } _dnf "$@" diff --git a/Completion/Unix/Command/_bibtex b/Completion/Unix/Command/_bibtex new file mode 100644 index 000000000..8db38a244 --- /dev/null +++ b/Completion/Unix/Command/_bibtex @@ -0,0 +1,5 @@ +#compdef bibtex + +# bibtex only works when the *.aux file exists, but complete the *.tex file in +# case it hasn't been compiled yet. +_files -g '*.(aux|tex)(:r)' diff --git a/Completion/Unix/Command/_dig b/Completion/Unix/Command/_dig new file mode 100644 index 000000000..2b851c91f --- /dev/null +++ b/Completion/Unix/Command/_dig @@ -0,0 +1,85 @@ +#compdef dig + +_dns_types() { + local expl + _description dns-types expl 'DNS type' + compadd "$@" "$expl[@]" -M 'm:{a-z}={A-Z}' \ + ANY A AAAA AFSDB APL AXFR CAA CDNSKEY CDS CERT CNAME DHCID DLV DNAME \ + DNSKEY DS HIP HINFO IPSECKEY IXFR KEY KX LOC MX NAPTR NS NSEC NSEC3 \ + NSEC3PARAM OPT PTR RRSIG RP SIG SOA SPF SRV SSHFP TA TKEY TLSA TSIG TXT +} + +local curcontext="$curcontext" state line expl +local -a alts args +[[ -prefix + ]] && args=( + '*+'{no,}'tcp[use TCP instead of UDP for queries]' + '*+'{no,}'ignore[ignore truncation in UDP responses]' + '*+domain=[set search list to single domain]:domain:_hosts' + '*+'{no,}'search[use search list defined in resolv.conf]' + '*+'{no,}'showsearch[show intermediate results in domain search]' + '*+'{no,}'aaonly[set aa flag in the query]' + '*+'{no,}'adflag[set the AD (authentic data) bit in the query]' + '*+'{no,}'cdflag[set the CD (checking disabled) bit in the query]' + '*+'{no,}'cl[display the CLASS whening printing the record]' + '*+'{no,}'ttlid[display the TTL whening printing the record]' + '*+'{no,}'recurse[set the RD (recursion desired) bit in the query]' + '*+'{no,}'nssearch[search all authoritative nameservers]' + '*+'{no,}'trace[trace delegation down from root]' + '*+'{no,}'cmd[print initial comment in output]' + '*+'{no,}'short[print terse output]' + '*+'{no,}'identify[print IP and port of responder]' + '*+'{no,}'comments[print comment lines in output]' + '*+'{no,}'stats[print statistics]' + '*+'{no,}'qr[print query as it was sent]' + '*+'{no,}'question[print question section of a query]' + '*+'{no,}'answer[print answer section of a reply]' + '*+'{no,}'authority[print authority section of a reply]' + '*+'{no,}'additional[print additional section of a reply]' + '*+'{no,}'all[set all print/display flags]' + '*+time=[set query timeout]:timeout (seconds)' + '*+tries=[specify number of UDP query attempts]:tries' + '*+retry=[specify number of UDP query retries]:retries' + '*+ndots=[specify number of dots to be considered absolute]:dots' + '*+bufsize=[specify UDP buffer size]:size (bytes)' + '*+edns=[specify EDNS version for query]:version (0-255)' + '*+noedns[clean EDNS version]' + '*+'{no,}'multiline[verbose multi-line output]' + '*+'{no,}'onesoa[AXFR prints only one soa record]' + '*+'{no,}"fail[don't try next server on SERVFAIL]" + '*+'{no,}'besteffort[try to parse even malformed messages]' + '*+'{no,}'dnssec[request DNSSEC records]' + '*+'{no,}'sigchase[chase DNSSEC signature chains]' + '*+trusted-key=[specify file conrtaing trusted kets]:file:_files' + '*+'{no,}'topdown[do DNSSEC validation in top down mode]' + '*+'{no,}'nsid[include EDNS name server ID request in query]' +) +_arguments -s -C $args \ + '(- *)-h[display help information]' \ + '(- *)-v[display version information]' \ + '*-c+[specify class]:class:compadd -M "m:{a-z}={A-Z}" - IN CS CH HS' \ + '*-b+[specify source IP]:IP' \ + '*-f+[batch mode, read arguments from file]:file:_files' \ + '*-m[enable memory usage debugging]' \ + '*-p+[specify port number]:port:_ports' \ + '*-4[use IPv4 only]' \ + '*-6[use IPv6 only]' \ + '*-t+[specify type]:type:_dns_types' \ + '*-q+[specify host name to query]:host:_hosts' \ + '*-x+[reverse lookup]:IP address' \ + '*-k+[specify TSIG key file]:file:_files' \ + '*-y+[specify TSIG key]:hmac\:name\:key' \ + '*: :->args' && ret=0 + +if [[ -n $state ]]; then + if compset -P @; then + _wanted hosts expl 'DNS server' _hosts && ret=0; + else + case $#line in + <3->) alts+=( 'classes:query class:compadd -M "m:{a-z}={A-Z}" - IN CS CH HS' ) ;& + 2) alts+=( 'types:query type:_dns_types' ) ;; + esac + _alternative 'hosts:host:_hosts' $alts && ret=0 + fi +fi + +return ret diff --git a/Completion/Unix/Command/_elfdump b/Completion/Unix/Command/_elfdump index ee92402d2..065f4b97f 100644 --- a/Completion/Unix/Command/_elfdump +++ b/Completion/Unix/Command/_elfdump @@ -2,10 +2,6 @@ local -a args -_elf_file() { - [[ -x $REPLY || $REPLY = (core*|*.([ao]|so|elf)) ]] -} - args=( '-c[dump section header information]' '-d[dump .dynamic section]' @@ -38,7 +34,7 @@ case $OSTYPE in '-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:)'" + "*:elf file:_object_files" ) ;; freebsd*) args+=( '-a[dump all information]' ) ;; diff --git a/Completion/Unix/Command/_getent b/Completion/Unix/Command/_getent index b9aff6642..b9aff6642 100755..100644 --- a/Completion/Unix/Command/_getent +++ b/Completion/Unix/Command/_getent diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index 6e8e9c665..5f137d009 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -1941,7 +1941,7 @@ _git-config () { 'branch.*.pushremote:what remote git push should push to::__git_remotes' 'branch.*.rebase:rebase on top of fetched branch::->bool:false' 'browser.*.cmd:browser command to use:browser:_cmdstring' - 'browser.*.path:path to use for the browser:absolute browser path:_files -g "*(*)"' + 'browser.*.path:path to use for the browser:absolute browser path:_absolute_command_paths' clean.requireForce:'require --force for git clean to actually do something::->bool:true' color.branch:'color output of git branch::->color-bool:false' color.branch.current:'color of the current branch::->color' @@ -2013,7 +2013,7 @@ _git-config () { diff.suppressBlankEmpty:'inhibit printing space before empty output lines::->bool:false' diff.tool:'diff tool to use::__git_difftools' 'difftool.*.cmd:command to invoke for the diff tool::_cmdstring' - 'difftool.*.path:path to use for the diff tool:absolute diff tool path:_files -g "*(*)"' + 'difftool.*.path:path to use for the diff tool:absolute diff tool path:_absolute_command_paths' difftool.prompt:'prompt before each invocation of the diff tool::->bool:true' diff.wordRegex:'regex used to determine what a word is when performing word-by-word diff:regular expression:->string' diff.guitool:'diff tool with gui to use::__git_difftools' @@ -2180,7 +2180,7 @@ _git-config () { mailmap.file:'augmenting mailmap file:mailmap file:_files' man.viewer:'man viewer to use for help in man format::__git_man_viewers' 'man.*.cmd:the command to invoke the specified man viewer:man command:_cmdstring' - 'man.*.path:path to use for the man viewer:absolute man tool path:_files -g "*(*)"' + 'man.*.path:path to use for the man viewer:absolute man tool path:_absolute_command_paths' merge.branchdesc:'populate the log message with the branch description text as well::->bool:false' merge.conflictstyle:'style used for conflicted hunks::->merge.conflictstyle:merge' merge.defaultToUpstream:'merge the upstream branches configured for the current branch by default::->bool:true' @@ -2194,7 +2194,7 @@ _git-config () { 'merge.*.name:human-readable name for custom low-level merge driver:name:->string' 'merge.*.driver:command that implements a custom low-level merge driver:merge command:_cmdstring' 'merge.*.recursive:low-level merge driver to use when performing internal merge between common ancestors::__git_builtin_merge_drivers' - 'mergetool.*.path:path to use for the merge tool:absolute merge tool path:_files -g "*(*)"' + 'mergetool.*.path:path to use for the merge tool:absolute merge tool path:_absolute_command_paths' 'mergetool.*.cmd:command to invoke for the merge tool:merge command:_cmdstring' 'mergetool.*.trustExitCode:trust the exit code of the merge tool::->bool:false' mergetool.keepBackup:'keep the original file with conflict markers::->bool:true' @@ -3710,7 +3710,7 @@ _git-send-email () { '--smtp-encryption=[specify encryption method to use]: :__git_sendemail_smtpencryption_values' \ '--smtp-domain=[specify FQDN used in HELO/EHLO]: :_domains' \ '--smtp-pass=[specify password to use for SMTP-AUTH]::password' \ - '--smtp-server=[specify SMTP server to connect to]:smtp server:_hosts' \ + '--smtp-server=[specify SMTP server to connect to, or sendmail command]: : __git_sendmail_smtpserver_values' \ '--smtp-server-port=[specify port to connect to SMTP server on]:smtp port:_ports' \ '--smtp-server-option=[specify the outgoing SMTP server option to use]:SMPT server option' \ '--smtp-ssl-cert-path=[path to ca-certificates (directory or file)]:ca certificates path:_files' \ @@ -5623,8 +5623,8 @@ __git_commits () { (( $+functions[__git_heads] )) || __git_heads () { - __git_heads_local - __git_heads_remote + __git_heads_local "$@" + __git_heads_remote "$@" } (( $+functions[__git_heads_local] )) || @@ -5815,7 +5815,7 @@ __git_commit_ranges () { if [[ ${PREFIX} = (#b)((\\|)\^)* ]]; then compset -p ${#match[1]} else - suf=( -S .. -r '.@~ ^:\t\n\-' ) + suf=( -S .. -r '@~ \^:\t\n\-' ) fi fi expl=( $* $suf ) @@ -6119,7 +6119,7 @@ __git_tree_files () { shift (( at_least_one_tree_added = 0 )) for tree in $*; do - tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree $extra_args --name-only -z $tree $Path 2>/dev/null)"}) + tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree -r $extra_args --name-only -z $tree 2>/dev/null)"}) __git_command_successful $pipestatus && (( at_least_one_tree_added = 1 )) done @@ -6859,6 +6859,11 @@ __git_sendemail_suppresscc_values () { all:'avoid all auto Cc values' } +(( $+functions[__git_sendmail_smtpserver_values] )) || +__git_sendmail_smtpserver_values() { + _alternative "smtp hosts:host:_hosts" "sendmail command: :_absolute_command_paths" +} + (( $+functions[__git_colors] )) || __git_colors () { declare -a expl diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man index 81ac40bc2..0534db753 100644 --- a/Completion/Unix/Command/_man +++ b/Completion/Unix/Command/_man @@ -37,7 +37,10 @@ _man() { mrd=(${^_manpath/\%L/${LANG:-En_US.ASCII}}/mandb(N)) - local sect + # $sect is from the command line, the "3p" in "man 3p memcpy" + # $sect_dirname is from the filesystem, the "3" in "/usr/share/man/man3" + # These are used by _man_pages + local sect sect_dirname if [[ $OSTYPE = solaris* ]]; then sect=${${words[(R)-s*]#-s}:-$words[$words[(i)-s]+1]} elif [[ -n ${sect:=$words[$words[(i)-S]+1]} || -n ${sect:=$MANSECT} ]]; then @@ -49,7 +52,7 @@ _man() { fi if [[ $sect = (<->*|1M|l|n) || $sect = \(*\|*\) ]]; then - dirs=( $^_manpath/(sman|man|cat)${~sect}/ ) + dirs=( $^_manpath/(sman|man|cat)${~sect%%[^0-9]#}/ ) awk="\$2 == \"$sect\" {print \$1}" else dirs=( $^_manpath/(sman|man|cat)*/ ) @@ -69,8 +72,8 @@ _man() { _tags manuals.${^sects} while _tags; do - for sect in $sects; do - _requested manuals.$sect expl "manual page, section $sect" _man_pages && + for sect_dirname in $sects; do + _requested manuals.$sect_dirname expl "manual page, section $sect_dirname" _man_pages && ret=0 done (( ret )) || return 0 @@ -78,7 +81,7 @@ _man() { return 1 else - sect= + sect_dirname= _wanted manuals expl 'manual page' _man_pages fi } @@ -107,8 +110,8 @@ _man_pages() { matcher= fi - pages=( ${(M)dirs:#*$sect/} ) - compfiles -p pages '' '' "$matcher" '' dummy '*' + pages=( ${(M)dirs:#*$sect_dirname/} ) + compfiles -p pages '' '' "$matcher" '' dummy "*${(b)sect}*" pages=( ${^~pages}(N:t) ) (($#mrd)) && pages[$#pages+1]=($(awk $awk $mrd)) @@ -119,11 +122,11 @@ _man_pages() { [[ $OSTYPE = solaris* ]] && sopt='-s ' if ((CURRENT > 2)) || - ! zstyle -t ":completion:${curcontext}:manuals.$sect" insert-sections + ! zstyle -t ":completion:${curcontext}:manuals.$sect_dirname" insert-sections then compadd "$@" - ${pages%$~suf} else - compadd "$@" -P "$sopt$sect " - ${pages%$~suf} + compadd "$@" -P "$sopt$sect_dirname " - ${pages%$~suf} fi } diff --git a/Completion/Unix/Command/_mtools b/Completion/Unix/Command/_mtools index 63851b86f..63851b86f 100755..100644 --- a/Completion/Unix/Command/_mtools +++ b/Completion/Unix/Command/_mtools diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm index d171ef5a3..73d7508b4 100644 --- a/Completion/Unix/Command/_nm +++ b/Completion/Unix/Command/_nm @@ -2,11 +2,7 @@ local args files variant -_nm_object_file() { - [[ -x $REPLY || $REPLY = *.([ao]|so|elf) ]] -} - -files="*:object file:_files -g '*(-.e,_nm_object_file,)'" +files="*:object file:_object_files" args=( '(-A -o --print-file-name)'{-A,-o,--print-file-name}'[print name of input file on each line]' '(--demangle)-C[decode symbol names]' diff --git a/Completion/Unix/Command/_objdump b/Completion/Unix/Command/_objdump index 607719a19..cc213d911 100644 --- a/Completion/Unix/Command/_objdump +++ b/Completion/Unix/Command/_objdump @@ -1,8 +1,3 @@ #compdef objdump -# borrowed from _nm_object_file -_objdump_object_file() { - [[ -x $REPLY || $REPLY = *.([ao]|so|elf) ]] -} - -_arguments -- '*:object file:_files -g "*(-.e,_objdump_object_file,)"' +_arguments -- '*:object file:_object_files' diff --git a/Completion/Unix/Command/_readelf b/Completion/Unix/Command/_readelf index 9312ea864..a474a8dc4 100644 --- a/Completion/Unix/Command/_readelf +++ b/Completion/Unix/Command/_readelf @@ -2,10 +2,6 @@ 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 @@ -29,7 +25,7 @@ args=( '(-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:)'" + "*:elf file:_object_files" ) case $variant in diff --git a/Completion/Unix/Type/_absolute_command_paths b/Completion/Unix/Type/_absolute_command_paths new file mode 100644 index 000000000..e9ab17023 --- /dev/null +++ b/Completion/Unix/Type/_absolute_command_paths @@ -0,0 +1,29 @@ +#autoload + +# This function completes 'ls' to '/bin/ls' +_hashed_absolute_command_paths() { + local -aU set_of_dirs_of_hashed_commands=( ${^commands%/*}/ ) + local i + integer ret=1 + for i in $set_of_dirs_of_hashed_commands + do + compadd -M "l:|=$i" "$expl[@]" -a 'commands[(R)${~i}[^/]#]' + ret=0 + done + return ret +} + +# This function completes absolute pathnames of executables, e.g., /etc/rc.local +_typed-in_absolute_command_paths() { + # TODO: the description "full path to an executable" and tag in the caller are ignored by _path_files + _path_files -/ -g '*(-*)' -P / -W / +} + +_absolute_command_paths() { + _alternative \ + 'commands:hashed command by absolute path:_hashed_absolute_command_paths' \ + 'commands:full path to an executable:_typed-in_absolute_command_paths' +} + + +_absolute_command_paths "$@" diff --git a/Completion/Unix/Type/_list_files b/Completion/Unix/Type/_list_files index e04392d1d..6c52bc1f4 100644 --- a/Completion/Unix/Type/_list_files +++ b/Completion/Unix/Type/_list_files @@ -36,7 +36,7 @@ for elt in $stylevals; do break ;; - (*($what|all|true|1|yes)[^=]#) + ([^=]#($what|all|true|1|yes)[^=]#) # always use long format (( ok = 1 )) break diff --git a/Completion/Unix/Type/_mime_types b/Completion/Unix/Type/_mime_types index 18a332e09..18a332e09 100755..100644 --- a/Completion/Unix/Type/_mime_types +++ b/Completion/Unix/Type/_mime_types diff --git a/Completion/Unix/Type/_object_files b/Completion/Unix/Type/_object_files new file mode 100644 index 000000000..31a13aefc --- /dev/null +++ b/Completion/Unix/Type/_object_files @@ -0,0 +1,11 @@ +#autoload + +local expl + +_description files expl 'object file' + +__object_file() { + [[ -x $REPLY || $REPLY = *.([ao]|so|elf)(.<->)## || $REPLY = (core*|*.core) ]] +} + +_files -g '*(-.e,__object_file,)' diff --git a/Completion/Unix/Type/_path_commands b/Completion/Unix/Type/_path_commands index 423563c0d..66795ae0f 100644 --- a/Completion/Unix/Type/_path_commands +++ b/Completion/Unix/Type/_path_commands @@ -82,6 +82,9 @@ if [[ -n $need_desc ]]; then else _wanted commands expl 'external command' compadd "$@" -k commands && ret=0 fi +# TODO: this is called from '_command_names -e' which is typically used in +# contexts (such as _env) that don't accept directory names. Should this +# 'if' block move up to the "_command_names -" branch of _command_names? if [[ -o path_dirs ]]; then local -a path_dirs path_dirs=(${^path}/*(/N:t)) diff --git a/Completion/X/Command/_kfmclient b/Completion/X/Command/_kfmclient index 87080cf90..87080cf90 100755..100644 --- a/Completion/X/Command/_kfmclient +++ b/Completion/X/Command/_kfmclient diff --git a/Completion/X/Command/_mplayer b/Completion/X/Command/_mplayer index f2f4c3d45..a913960fe 100644 --- a/Completion/X/Command/_mplayer +++ b/Completion/X/Command/_mplayer @@ -14,7 +14,7 @@ _x_arguments -C -s \ '-aofile:file:_files' \ '(-nosound)*-aop[specify audio output filter]:audio output filter:->audio-plugins' \ '-aspect:ratio' \ - '-audiofile:audio file:_files -g "(#i)*.(wav|mp3|ogg)(-.)"' \ + '-audiofile:audio file:_files -g "(#i)*.(wav|mp3|ogg|opus)(-.)"' \ -autoq:quality -autosync:factor \ -bandwidth:bandwidth\ value -benchmark -bpp:depth \ '(-nocache)-cache:cache size (kb)' \ @@ -115,7 +115,7 @@ case "$state" in _tags files urls while _tags; do _requested files expl 'media file' _files -g \ - "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4a|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && ret=0 + "*.(#i)(asf|asx|avi|flac|flv|m1v|m2p|m2v|m4a|m4v|mjpg|mka|mkv|mov|mp3|mp4|mpe|mpeg|mpg|ogg|ogm|ogv|opus|qt|rm|ts|vob|wav|webm|wma|wmv)(-.)" && ret=0 if _requested urls; then while _next_label urls expl URL; do _urls "$expl[@]" && ret=0 diff --git a/Completion/Zsh/Command/_zed b/Completion/Zsh/Command/_zed index 184234b02..184234b02 100755..100644 --- a/Completion/Zsh/Command/_zed +++ b/Completion/Zsh/Command/_zed |