diff options
Diffstat (limited to 'Completion/Unix/Command')
100 files changed, 2421 insertions, 1385 deletions
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 |