diff options
Diffstat (limited to 'Completion/Unix')
27 files changed, 2329 insertions, 609 deletions
diff --git a/Completion/Unix/Command/.distfiles b/Completion/Unix/Command/.distfiles index cc47a7a0b..a89b7d923 100644 --- a/Completion/Unix/Command/.distfiles +++ b/Completion/Unix/Command/.distfiles @@ -2,6 +2,7 @@ DISTFILES_SRC=' .distfiles _a2ps _aap +_adb _ant _antiword _apachectl @@ -110,6 +111,7 @@ _last _ldd _less _links +_ln _loadkeys _locate _look @@ -139,6 +141,7 @@ _mysqldiff _ncftp _netcat _nice +_nm _nmap _notmuch _npm @@ -207,6 +210,7 @@ _subversion _sudo _surfraw _sysctl +_systemctl _tar _tardy _tcpdump @@ -224,6 +228,8 @@ _toilet _topgit _totd _tracepath +_tree +_twidge _twisted _unace _uname diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb new file mode 100644 index 000000000..2e36046c7 --- /dev/null +++ b/Completion/Unix/Command/_adb @@ -0,0 +1,541 @@ +#compdef adb -value-,ADB_TRACE,-default- -value-,ANDROID_SERIAL,-default- -value-,ANDROID_LOG_TAGS,-default- + +local ADB_DEVICE_SPECIFICATION LOG_REDIRECT + +_adb() { + # rely on localoptions + setopt nonomatch + + ADB_DEVICE_SPECIFICATION="" + + if [[ $1 = -l ]]; then + # Run to load _adb and associated functions but do + # nothing else. + return + fi + + if [[ $service = -value-* ]]; then + #_message compstate=$compstate[parameter] + case $compstate[parameter] in + (ADB_TRACE) + _adb_trace_opts + ;; + + (ANDROID_SERIAL) + _adb_device_serial + ADB_DEVICE_SPECIFICATION="-s ${ANDROID_SERIAL}" + ;; + + (ANDROID_LOG_TAGS) + _adb_logcat_filter_specification + ;; + + esac + # We do not handle values anywhere else. + return + fi + + local -a ALL_ADB_COMMANDS + ALL_ADB_COMMANDS=( + "connect" + "disconnect" + "shell" + "wait-for-device" + "push" + "pull" + "logcat" + "jdwp" + "bugreport" + "version" + "forward" + "install" + "uninstall" + "help" + "start-server" + "kill-server" + "devices" + "get-state" + "get-serialno" + "status-window" + "remount" + "reboot" + "reboot-bootloader" + "root" + "usb" + "tcpip" + "ppp" + ) + + (( $+functions[_adb_device_specification] )) && _adb_device_specification + + adb ${=ADB_DEVICE_SPECIFICATION} shell exit 2>/dev/null || { + # early bail-out until a single valid device/emulator is specified and up-and-running + _message -r "No (started) device specified, completions do not yet work" + _arguments \ + '(-d -e )-s[serial]: :_adb_device_serial' \ + '( -e -s)-d[device]' \ + '(-d -s)-e[emulator]' \ + '*:"options":_adb_options_handler' + + return; + } + + (( $+functions[_adb_check_log_redirect] )) && _adb_check_log_redirect + + (( $+functions[_adb_dispatch_command] )) && _adb_dispatch_command +} + +(( $+functions[_adb_dispatch_command] )) || +_adb_dispatch_command () { + local curcontext="${curcontext}" + local integer last_command_pos=-1 + + (( $+functions[_adb_sanitize_context] )) && _adb_sanitize_context + if [[ ${last_command_pos} -gt 0 ]] + then + shift ${last_command_pos}-1 words + CURRENT=$(( ${CURRENT} - ${last_command_pos} + 1 )) + fi + + case ${curcontext} in + (*:adb:shell) + (( $+functions[_adb_dispatch_shell] )) && _adb_dispatch_shell + ;; + (*:adb:connect|*:adb:disconnect) + (( $+functions[_adb_dispatch_connection_handling] )) && _adb_dispatch_connection_handling + ;; + (*:adb:logcat) + (( $+functions[_adb_dispatch_logcat] )) && _adb_dispatch_logcat + ;; + (*:adb:push) + (( $+functions[_adb_dispatch_push] )) && _adb_dispatch_push + ;; + (*:adb:pull) + (( $+functions[_adb_dispatch_pull] )) && _adb_dispatch_pull + ;; + (*:adb:install) + (( $+functions[_adb_dispatch_install] )) && _adb_dispatch_install + ;; + (*:adb:uninstall) + (( $+functions[_adb_dispatch_uninstall] )) && _adb_dispatch_uninstall + ;; + (*) + _arguments \ + '(-d -e)-s["serial"]: :_adb_device_serial' \ + '(-s -e)-d["device"]' \ + '(-d -s)-e["emulator"]' \ + '*:"options":_adb_options_handler' + ;; + esac +} + +(( $+functions[_adb_sanitize_context] )) || +_adb_sanitize_context () { + local -a mywords + for adbcommand in "${ALL_ADB_COMMANDS[@]}" + do + if [[ -n "${adbcommand}" ]] && [[ ${words[(I)${adbcommand}]} -gt 0 ]] + then + last_command_pos=${words[(I)${adbcommand}]} + mywords[${last_command_pos}]=${adbcommand} + fi + done + ##expand unquoted to remove sparse elements + mywords=( ${mywords[@]} ) + curcontext="${curcontext}${mywords[-1]}" +} + +(( $+functions[_adb_device_specification] )) || +_adb_device_specification () { + local integer i=1 + foreach word ($words) + do + i=$(( ++i )) + case ${words[$i]} in + (-d|-e) + ADB_DEVICE_SPECIFICATION="${words[$i]}" + break + ;; + (-s) + ADB_DEVICE_SPECIFICATION="-s ${words[$i + 1]}" + break + ;; + (-*) + continue + ;; + (*) + break + ;; + esac + done +} + +(( $+functions[_adb_dispatch_shell] )) || +_adb_dispatch_shell () { + if [[ ${#words} -le 2 ]] + then + (( $+functions[_adb_shell_commands_handler] )) && _adb_shell_commands_handler + return + fi + + case ${words[2]} in + (am) + (( $+functions[_adb_activity_manager_handler] )) && _adb_activity_manager_handler + ;; + (pm) + (( $+functions[_adb_package_manager_handler] )) && _adb_package_manager_handler + ;; + (*) + _arguments '*:adb_remote_folder:_adb_remote_folder' + ;; + esac +} + +(( $+functions[_adb_pm_list] )) || +_adb_pm_list () { + case ${words[4]} in + (packages) + _arguments -s '-f[see their associated file]' \ + ':' + ;; + (permissions) + _arguments -s '-g[organize by group]' \ + '-f[print all information]' \ + '-d[only list dangerous pemissions]' \ + '-u[only list user visible permissions]' \ + '-s[short summary]' \ + ':' + ;; + (permission-groups) + ;; + (instrumentation) + _arguments -s '-f[see their associated file]' \ + ':' + ;; + (features) + ;; + (*) + _wanted pm_list_argument expl 'pm list argument' compadd packages permission-groups permissions instrumentation features + ;; + esac +} + +(( $+functions[_adb_intent_handler] )) || +_adb_intent_handler () { + _message -r "<INTENT> specifications include these flags: + [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] + [-c <CATEGORY> [-c <CATEGORY>] ...] + [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...] + [--esn <EXTRA_KEY> ...] + [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...] + [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...] + [-n <COMPONENT>] [-f <FLAGS>] + [--grant-read-uri-permission] [--grant-write-uri-permission] + [--debug-log-resolution] + [--activity-brought-to-front] [--activity-clear-top] + [--activity-clear-when-task-reset] [--activity-exclude-from-recents] + [--activity-launched-from-history] [--activity-multiple-task] + [--activity-no-animation] [--activity-no-history] + [--activity-no-user-action] [--activity-previous-is-top] + [--activity-reorder-to-front] [--activity-reset-task-if-needed] + [--activity-single-top] + [--receiver-registered-only] [--receiver-replace-pending] + [<URI>]" +} + +(( $+functions[_adb_activity_manager_handler] )) || +_adb_activity_manager_handler () { + if [[ ${#words} -le 3 ]] + then + _wanted am_argument expl 'am argument' compadd start startservice broadcast instrument profile + return + fi + case ${words[3]} in + (start) + _arguments -s '-D[enable debugging]' \ + '-W[wait for launch to complete]' \ + '*:intent:_adb_intent_handler' + ;; + (startservice) + _arguments -s '*:intent:_adb_intent_handler' + ;; + (broadcast) + _arguments -s '*:intent:_adb_intent_handler' + ;; + (instrument) + _arguments -s '-r[print raw results]' \ + '-e[set argument NAME to VALUE]:<NAME> <VALUE>:' \ + '-p[write profiling data to FILE]:<FILE>:' \ + '-w[wait for instrumenation to finish]' \ + ':' + ;; + (profile) + _message -r "<PROCESS> start/stop <FILE>" + ;; + esac +} + +(( $+functions[_adb_package_manager_handler] )) || +_adb_package_manager_handler () { + case ${words[3]} in + (list) + (( $+functions[_adb_pm_list] )) && _adb_pm_list + ;; + (path) + (( $+functions[_adb_installed_packages] )) && _adb_installed_packages + ;; + (enable) + (( $+functions[_adb_installed_packages] )) && _adb_installed_packages + ;; + (disable) + (( $+functions[_adb_installed_packages] )) && _adb_installed_packages + ;; + (setInstallLocation) + _wanted set_installlcation expl 'install location' compadd -d "(0:auto 1:internal 2:external)" 0 1 2 + ;; + (getInstallLocation) + ;; + (*) + _wanted pm_argument expl 'pm argument' compadd list path install unistall enable disable setInstallLocation getInstallLocation + ;; + esac +} + +(( $+functions[_adb_dispatch_uninstall] )) || +_adb_dispatch_uninstall () { + argcount=${#${(M)words#-*}} + if [[ $CURRENT -gt (( argcount + 2 )) ]] + then + _message -r "Notice: you can only uninstall one package at a time" + return + fi + + _arguments \ + '-k["keep data and cache"]' \ + '*:"installed package":_adb_installed_packages' +} + +(( $+functions[_adb_dispatch_install] )) || +_adb_dispatch_install () { + argcount=${#${(M)words#-*}} + if [[ $CURRENT -gt (( argcount + 2 )) ]] + then + _message -r "Notice: you can only install one package at a time" + return + fi + + _arguments \ + '-l["forward lock"]' \ + '-r["reinstall"]' \ + '-s["install on sd"]' \ + '*:"select apk file":_path_files -g "*(/)|*.apk"' +} + +(( $+functions[_adb_dispatch_push] )) || +_adb_dispatch_push () { + if [[ ${#words} -gt 3 ]] + then + _message -r "Notice: you can only push a single item at a time" + return + fi + if [[ ${#words} -gt 2 ]] + then + _arguments '*:adb_remote_folder:_adb_remote_folder' + else + _arguments '*:"local file/folder":_files' + fi +} + +(( $+functions[_adb_dispatch_pull] )) || +_adb_dispatch_pull () { + if [[ ${#words} -gt 3 ]] + then + _message -r "Notice: you can only pull a single item at a time" + return + fi + if [[ ${#words} -gt 2 ]] + then + _arguments '*:"local file/folder":_files' + else + _arguments '*:adb_remote_folder:_adb_remote_folder' + fi +} + +(( $+functions[_adb_dispatch_connection_handling] )) || +_adb_dispatch_connection_handling () { + if compset -P '*:' + then + local expl + _wanted ports expl port compadd "$@" 5555 + else + _hosts -qS: + fi +} + +(( $+functions[adb_check_log_redirect] )) || +_adb_check_log_redirect () { + LOG_REDIRECT=${$(adb ${=ADB_DEVICE_SPECIFICATION} shell getprop log.redirect-stdio)// +/} + [[ ${LOG_REDIRECT[1,4]} == "true" ]] && _message -r "Notice: stdio log redirection enabled on the device, so some completions will not work" +} + +(( $+functions[_adb_trace_opts] )) || +_adb_trace_opts() { + _values -s , 'adb trace options' \ + '(1 adb sockets packets rwx usb sync sysdeps transport jdwp)all' \ + '(all adb sockets packets rwx usb sync sysdeps transport jdwp)1' \ + 'adb' \ + 'sockets' \ + 'packets' \ + 'rwx' \ + 'usb' \ + 'sync' \ + 'sysdeps' \ + 'transport' \ + 'jdwp' +} + +(( $+functions[_adb_device_serial] )) || +_adb_device_serial() { + local expl + _wanted dev_serial expl 'available devices' compadd $(command adb devices | sed -n 's/^\([^[:space:]]*\)\t.*$/\1/p') +} + +(( $+functions[_adb_logcat_filter_specification] )) || +_adb_logcat_filter_specification() { + zstyle ":completion:${curcontext}:" cache-policy _adb_cache_policy_single_command + + local cacheid=logcat_filter_cache_${$(adb ${=ADB_DEVICE_SPECIFICATION} get-serialno)} + typeset -a logcat_filter_tags + if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid" + then + logcat_filter_tags=( $(command adb ${=ADB_DEVICE_SPECIFICATION} logcat -d | sed -n 's#^[VDIWEF]/\([^[:space:](]*\).*#\1#p' |sort | uniq) ) + _store_cache "$cacheid" logcat_filter_tags + fi + local expl + if compset -P '*:' + then + _wanted filter expl filter compadd W S E I D V \* + else + _wanted filtertags expl filtertags compadd -qS: ${logcat_filter_tags[@]} \* + fi +} + +(( $+functions[_adb_dispatch_logcat] )) || +_adb_dispatch_logcat() { + _arguments \ + '(-c -g)-s[set default filter to silent]' \ + '(-c -g)-f[log output to file (defaults to stdout)]:logfile:_files' \ + '(-c -g -d)-r[rotate log every kbytes (default 16, requires -f)]:logsize:_guard "[0-9]#" "numeric value"' \ + '(-c -g -d)-n[max number of rotated logs (default 4)]:number :_guard "[0-9]#" "numeric value"' \ + '(-c -g -d)-v[log format]:format: _values "format" brief process tag thread raw time threadtime long' \ + '(-d -t -g)-c[clear log]' \ + '(-c -g)-d[dump log]' \ + '(-c -g)-t[print only recent lines (implies -d)]:linecount:_guard "[0-9]#" "numeric value"' \ + '(-c -g)-B[output log in binary]' \ + '(-c -g)*:filtering:_adb_logcat_filter_specification' +} + +(( $+functions[_adb_options_handler] )) || +_adb_options_handler() { + local expl + _wanted adb_options expl 'adb options' compadd "${ALL_ADB_COMMANDS[@]}" +} + +(( $+functions[_adb_shell_commands_handler] )) || +_adb_shell_commands_handler() { + local expl + _wanted adb_shell_commands expl 'adb shell commands' compadd ls pm am mkdir rmdir rm cat +} + +(( $+functions[_adb_any_device_available] )) || +_adb_any_device_available() { + _any_device_available=${#$(adb devices | sed -n 's/^\([^[:space:]]*\)\t.*$/\1/p')} +} + +(( $+functions[_adb_device_available] )) || +_adb_device_available() { + [[ $(adb ${=ADB_DEVICE_SPECIFICATION} get-state 2>&1) == "device" ]] && return 0 + return 1 +} + +(( $+functions[_adb_full_folder_scan] )) || +_adb_full_folder_scan() { + local -a rv; + rv=( ${$(adb ${=ADB_DEVICE_SPECIFICATION} shell 'for i in $(ls -d /*) + do + case $i in + /proc|/sys|/acct) + ;; + *) + ls -R $i + ;; + esac + done' )//'$\r'/} ) + for line in ${rv[@]}; + do + [[ ${line[1]} == '/' ]] && folder="${line%:}" && adb_device_folders+=$folder && continue; + adb_device_folders+=$folder/$line; + done +} + +(( $+functions[_adb_remote_folder] )) || +_adb_remote_folder () { + local expl + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _adb_cache_policy_daily + fi + local cacheid=package_cache_${$(adb ${=ADB_DEVICE_SPECIFICATION} get-serialno)} + typeset -a filesystem_content + if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid" + then + local -a adb_device_folders + _adb_full_folder_scan + # remove any duplicates and the initial slash => should still remove bare folders from it when it has children + filesystem_content=( ${(u)adb_device_folders#/} ) + _store_cache "$cacheid" filesystem_content + fi + _adb_device_available && \ + _wanted adb_remote_folder expl 'file/folder on device' _multi_parts $@ -i / filesystem_content +} + +(( $+functions[_adb_installed_packages] )) || +_adb_installed_packages() { + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _adb_cache_policy_single_command + fi + + local cacheid=package_cache_${$(adb ${=ADB_DEVICE_SPECIFICATION} get-serialno)} + typeset -a installed_packages + if _cache_invalid "$cacheid" || ! _retrieve_cache "$cacheid" + then + installed_packages=(${$( adb ${=ADB_DEVICE_SPECIFICATION} shell pm list packages )//#package:/}) + _store_cache "$cacheid" installed_packages + fi + + _wanted adb_installed_packages expl 'packages that are installed' compadd ${installed_packages} +} + +(( $+functions[_adb_cache_policy_single_command] )) || +_adb_cache_policy_single_command () { + typeset -a old + + # cache is valid for 1 minute + old=( "$1"(mm+1) ) + (( $#old )) +} + +(( $+functions[_adb_cache_policy_daily] )) || +_adb_cache_policy_daily () { + typeset -a old + + # cache is valid for a day + old=( "$1"(mh+12) ) + (( $#old )) +} + + + +_adb $@ diff --git a/Completion/Unix/Command/_at b/Completion/Unix/Command/_at index 4e2d28e27..8734e6b55 100644 --- a/Completion/Unix/Command/_at +++ b/Completion/Unix/Command/_at @@ -7,29 +7,29 @@ typeset -A opt_args case $service in atrm) _arguments \ - '-V[Print version number]' \ + '-V[print version number]' \ '*:job number:->jobs' ;; atq) _arguments \ - '-V[Print version number]' \ - '-q[Uses specified queue]:a-z+A-Z' + '-V[print version number]' \ + '-q[uses specified queue]:a-z+A-Z' ;; at|batch) _arguments \ - new-job \ - '-V[Print version number]' \ - '-q[Uses specified queue, uppercase acts as batch]:a-z+A-Z' \ - '-f[Read job from file rather than from stdin]:file:_files' \ - '-v[Show the time the job will be executed]' \ - '-m[Send mail even if there was no output]' \ + '-V[print version number]' \ + '-q[uses specified queue, uppercase acts as batch]:a-z+A-Z' \ + '-f[read job from file rather than from stdin]:file:_files' \ + '-v[show the time the job will be executed]' \ + '-m[send mail even if there was no output]' \ ':time:' \ - atq \ - '-l[Alias for atq]' \ + '-l[alias for atq]' \ - atrm \ - '-d[Alias for 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' esac case $state in diff --git a/Completion/Unix/Command/_bzr b/Completion/Unix/Command/_bzr index 47083ca49..83f6fd19b 100644 --- a/Completion/Unix/Command/_bzr +++ b/Completion/Unix/Command/_bzr @@ -259,7 +259,7 @@ case $cmd in ) ;; -(diff|dif|di) +(diff|dif|di|cdiff) args+=( '(-r --revision)'{--revision=,-r}'[revision]:revision:' '--diff-options=[options to pass to gdiff]:diff options:' diff --git a/Completion/Unix/Command/_ffmpeg b/Completion/Unix/Command/_ffmpeg index 8f9b2c9cb..6a4ba234d 100644 --- a/Completion/Unix/Command/_ffmpeg +++ b/Completion/Unix/Command/_ffmpeg @@ -21,6 +21,12 @@ typeset -A opt_args _wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a vcodecs } +(( $+functions[_ffmpeg_scodecs] )) || _ffmpeg_scodecs() { + local scodecs + scodecs=(copy ${${(M)${(f)"$(_call_program video-codecs $words[1] -codecs 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]]S[S[:space:]][D[:space:]][T[:space:]][[:space:]][^[:space:]]##*}//(#b)????????([^[:space:]]##)*/$match[1]}) + _wanted ffmpeg-video-codecs expl 'force video codec (''copy'' to copy stream)' compadd -a scodecs +} + (( $+functions[_ffmpeg_formats] )) || _ffmpeg_formats() { local formats formats=(${(ou)${=${(s:,:)${${(M)${(f)"$(_call_program formats $words[1] -formats 2>/dev/null)"}:#[[:space:]][D[:space:]][E[:space:]][[:space:]][^[:space:]]##*}//(#b)????([^[:space:]]##)*/$match[1]}}}}) @@ -84,6 +90,7 @@ typeset -A _ffmpeg_flags lastopt+=":$lastopt_description:" if (( $#lastopt_values )); then if [[ $lastopt_type == flags ]]; then + lastopt="*$lastopt" flagtype=${${lastopt%%:*}#-} lastopt+="->$flagtype" _ffmpeg_flags[$flagtype]="${lastopt_values[*]}" @@ -125,6 +132,7 @@ local -a _ffmpeg_argspecs lastopt+=":$lastopt_description:_files" elif [[ $lastopt == -[asv]pre ]]; then lastopt_takesargs=0 + lastopt="*$lastopt" lastopt+=": :_ffmpeg_presets" elif [[ $lastopt == -acodec ]]; then lastopt_takesargs=0 @@ -132,11 +140,16 @@ local -a _ffmpeg_argspecs elif [[ $lastopt == -vcodec ]]; then lastopt_takesargs=0 lastopt+=": :_ffmpeg_vcodecs" + elif [[ $lastopt == -scodec ]]; then + lastopt_takesargs=0 + lastopt+=": :_ffmpeg_scodecs" elif [[ $lastopt == -f ]]; then lastopt_takesargs=0 + lastopt="*$lastopt" lastopt+=": :_ffmpeg_formats" elif [[ $lastopt == -pix_fmt ]]; then lastopt_takesargs=0 + lastopt="*$lastopt" lastopt+=": :_ffmpeg_pix_fmts" elif [[ $example == bitstream_filter ]]; then lastopt_takesargs=0 diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index e062705ee..4a830f281 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -2,7 +2,7 @@ # Some parts of this completion's behaviour are configurable: # -# Say, you got your own git sub-commands (git will run a program `git-foo' +# 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 # via the user-command style: @@ -15,8 +15,31 @@ # # % zstyle ':completion:*:*:git:*' user-commands ${${(M)${(k)commands}:#git-*}/git-/} # -# You could even create a function _git-foo() to handle specific completion -# for that command. +# A better solution is to create a function _git-foo() to handle specific +# completion for that command. This also allows you to add command-specific +# 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.: +# +# % git bar <tab> +# +# ...will complete file names. If you do *not* want that fallback to be used, +# use the `use-fallback' style like this: +# +# % zstyle ':completion:*:*:git*:*' use-fallback false # TODO: There is still undocumented configurability in here. @@ -26,7 +49,7 @@ (( $+functions[_git-add] )) || _git-add () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args local ignore_missing= @@ -47,24 +70,25 @@ _git-add () { '--refresh[do not add files, but refresh their stat() info in index]' \ '--ignore-errors[continue adding if an error occurs]' \ $ignore_missing \ - '*:: :->file' && ret=0 + '*:: :->file' && return case $state in (file) - # TODO: Use __git_ignore_line_inside_arguments. declare -a ignored_files_alternatives - if [[ -n ${line[(I)-f|--force]} ]]; then + if [[ -n ${opt_args[(I)-f|--force]} ]]; then ignored_files_alternatives=( - 'ignored-modified-files:ignored modified files:__git_modified_files --ignored' - 'ignored-other-files:ignored other files:__git_other_files --ignored') + 'ignored-modified-files:ignored modified files:__git_ignore_line_inside_arguments __git_modified_files --ignored' + 'ignored-other-files:ignored other files:__git_ignore_line_inside_arguments __git_other_files --ignored') fi _alternative \ - 'modified-files::__git_modified_files' \ - 'other-files::__git_other_files' \ + 'modified-files::__git_ignore_line_inside_arguments __git_modified_files' \ + 'other-files::__git_ignore_line_inside_arguments __git_other_files' \ $ignored_files_alternatives && ret=0 ;; esac + + return ret } (( $+functions[_git-am] )) || @@ -72,11 +96,10 @@ _git-am () { local -a apply_options __git_setup_apply_options - # NOTE: --resolvemsg is only for internal use between git rebase and git am. + # NOTE: --rebasing and --resolvemsg are only for internal use between git + # rebase and git am. # TODO: --patch-format is undocumented. - # TODO: --ignore-date is incorrectly documented as being passed to git - # mailsplit. - # TODO: --rebasing, --rerere-autoupdate, and --no-rerere-autoupdate are + # TODO: --rerere-autoupdate and --no-rerere-autoupdate are # undocumented (and not implemented here). _arguments -S \ '(-s --signoff)'{-s,--signoff}'[add Signed-off-by: line to the commit message]' \ @@ -99,12 +122,12 @@ _git-am () { '--patch-format=-[specify format patches are in]:patch format:((mbox\:"mbox format" stgit-series\:"StGit patch series" stgit\:"stgit format"))' \ - '*:mbox file:_files' && ret=0 + '*:mbox file:_files' } (( $+functions[_git-archive] )) || _git-archive () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args declare -a backend_args @@ -145,6 +168,8 @@ _git-archive () { __git_tree_files ${PREFIX:-.} $line[1] && ret=0 ;; esac + + return ret } (( $+functions[_git-applymbox] )) || @@ -156,14 +181,14 @@ _git-applymbox () { '-u[encode commit information in UTF-8]' \ '(1)-c[restart command after fixing an unclean patch]:patch:_files -g ".dotest/0*"' \ ':mbox file:_files' \ - '::signoff file:__git_signoff_file' && ret=0 + '::signoff file:__git_signoff_file' } (( $+functions[_git-bisect] )) || _git-bisect () { # TODO: next subcommand is undocumented. Git-bisect.sh mentions that the # subcommand might be removed from the UI level. - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -C \ @@ -246,6 +271,8 @@ _git-bisect () { esac ;; esac + + return ret } (( $+functions[_git-branch] )) || @@ -306,12 +333,12 @@ _git-branch () { $dependent_modification_args \ "($l $c $m -D)-d[delete a fully merged branch]" \ "($l $c $m -d)-D[delete a branch]" \ - $dependent_deletion_args && ret=0 + $dependent_deletion_args } (( $+functions[_git-bundle] )) || _git-bundle () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -C \ @@ -359,6 +386,8 @@ _git-bundle () { esac ;; esac + + return ret } (( $+functions[_git-checkout] )) || @@ -371,7 +400,7 @@ _git-checkout () { new_branch_reflog_opt="(--patch)-l[create the new branch's reflog]" fi - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -w -C -s \ @@ -420,7 +449,7 @@ _git-checkout () { $tree_ish_arg \ $file_arg && ret=0 elif [[ -n ${opt_args[(I)-b|-B|-t|--track|--orphan]} ]]; then - _nothing && ret=0 + _nothing elif [[ -n $line[1] ]] && __git_is_treeish $line[1]; then __git_ignore_line __git_tree_files ${PREFIX:-.} $line[1] && ret=0 else @@ -428,6 +457,8 @@ _git-checkout () { fi ;; esac + + return ret } (( $+functions[_git-cherry-pick] )) || @@ -439,7 +470,7 @@ _git-cherry-pick () { '(-n --no-commit --ff)'{-n,--no-commit}'[do not make the actually commit]' \ '(-s --signoff --ff)'{-s,--signoff}'[add Signed-off-by line at the end of the commit message]' \ '(-e --edit -x -n --no-commit -s --signoff)--ff[fast forward, if possible]' \ - ': :__git_revisions' && ret=0 + ': :__git_revisions' } (( $+functions[_git-citool] )) || @@ -449,7 +480,7 @@ _git-citool () { (( $+functions[_git-clean] )) || _git-clean () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -w -C -S -s \ @@ -499,11 +530,13 @@ _git-clean () { $other_files_alt && ret=0 ;; esac + + return ret } (( $+functions[_git-clone] )) || _git-clone () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args # TODO: Argument to -o should be a remote name. @@ -538,6 +571,8 @@ _git-clone () { fi ;; esac + + return ret } (( $+functions[_git-commit] )) || @@ -589,7 +624,7 @@ _git-commit () { {-F,--file=}'[read commit message from given file]: :_files' \ {-m,--message=}'[use the given message as the commit message]:message' \ {-t,--template=}'[use file as a template commit message]:template:_files' \ - $amend_opt && ret=0 + $amend_opt } (( $+functions[_git-describe] )) || @@ -606,12 +641,12 @@ _git-describe () { '(--abbrev)--long[always show full format, even for exact matches]' \ '--match=[only consider tags matching glob pattern]:pattern' \ '--always[show uniquely abbreviated commit object as fallback]' \ - '*: :__git_committishs' && ret=0 + '*: :__git_committishs' } (( $+functions[_git-diff] )) || _git-diff () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args local -a diff_options @@ -689,11 +724,13 @@ _git-diff () { esac ;; esac + + return ret } (( $+functions[_git-fetch] )) || _git-fetch () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args local -a fetch_options @@ -717,11 +754,13 @@ _git-fetch () { fi ;; esac + + return ret } (( $+functions[_git-format-patch] )) || _git-format-patch () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args local -a diff_options @@ -770,6 +809,8 @@ _git-format-patch () { fi ;; esac + + return ret } (( $+functions[_git-gc] )) || @@ -779,7 +820,7 @@ _git-gc () { '--auto[check whether housekeeping is required]' \ '( --no-prune)--prune=[prune loose objects older than given date]: :__git_datetimes' \ '(--prune )--no-prune[do not prune any loose objects]' \ - '--quiet[suppress all progress reports]' && ret=0 + '--quiet[suppress all progress reports]' } (( $+functions[_git-grep] )) || @@ -794,7 +835,7 @@ _git-grep () { '--not[the following pattern must not match]') fi - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args # TODO: Need to implement -<num> as a shorthand for -C<num> @@ -871,17 +912,19 @@ _git-grep () { fi ;; esac + + return ret } (( $+functions[_git-gui] )) || _git-gui () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -C \ '--version[display version information]' \ ': :->command' \ - '*:: :->arg' + '*:: :->arg' && ret=0 case $state in (command) @@ -900,7 +943,7 @@ _git-gui () { case $line[1] in (blame) - _git-blame + _git-blame && ret=0 ;; (browser) _arguments -C \ @@ -914,7 +957,7 @@ _git-gui () { esac ;; (citool) - _git-citool + _git-citool && ret=0 ;; (version) _nothing @@ -925,6 +968,8 @@ _git-gui () { esac ;; esac + + return ret } (( $+functions[_git-init] )) || @@ -934,21 +979,23 @@ _git-init () { '--bare[create a bare repository]' \ '--template=[directory to use as a template for the object database]: :_directories' \ '--shared=[share repository amongst several users]:: :__git_repository_permissions' \ - ':: :_directories' && ret=0 + ':: :_directories' } (( $+functions[_git-log] )) || _git-log () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args - local -a log_options revision_options + local -a log_options revision_options diff_options __git_setup_log_options __git_setup_revision_options + __git_setup_diff_options _arguments -w -C -s \ $log_options \ $revision_options \ + $diff_options \ '(-)--[start file arguments]' \ '*:: :->commit-range-or-file' && ret=0 @@ -978,6 +1025,8 @@ _git-log () { ;; esac esac + + return ret } (( $+functions[_git-merge] )) || @@ -990,12 +1039,12 @@ _git-merge () { '-m[set the commit message to be used for the merge commit]:merge message' \ '( --no-rerere-autoupdate)--rerere-autoupdate[allow the rerere mechanism to update the index]' \ '(--rerere-autoupdate )--no-rerere-autoupdate[do not allow the rerere mechanism to update the index]' \ - '*: :__git_commits' && ret=0 + '*: :__git_commits' } (( $+functions[_git-mv] )) || _git-mv () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -w -C -S -s \ @@ -1012,11 +1061,13 @@ _git-mv () { 'directories:destination directory:_directories' && ret=0 ;; esac + + return ret } (( $+functions[_git-notes] )) || _git-notes () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -C \ @@ -1082,6 +1133,8 @@ _git-notes () { esac ;; esac + + return ret } (( $+functions[_git-pull] )) || @@ -1096,7 +1149,7 @@ _git-pull () { '(--rebase )--no-rebase[do not perform a rebase after fetching]' \ $fetch_options \ ': :__git_any_repositories' \ - '*: :__git_ref_specs' && ret=0 + '*: :__git_ref_specs' } (( $+functions[_git-push] )) || @@ -1122,7 +1175,7 @@ _git-push () { '(-q --quiet -v --verbose)'{-v,--verbose}'[output additional information]' \ '(-q --quiet)--progress[output progress information]' \ ':: :__git_any_repositories' \ - '*: :__git_ref_specs' && ret=0 + '*: :__git_ref_specs' } (( $+functions[_git-rebase] )) || @@ -1157,12 +1210,12 @@ _git-rebase () { '--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' \ ':upstream branch:__git_revisions' \ - '::working branch:__git_branch_names' && ret=0 + '::working branch:__git_branch_names' } (( $+functions[_git-reset] )) || _git-reset () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 typeset -A opt_args _arguments -w -C -s \ @@ -1186,6 +1239,8 @@ _git-reset () { __git_tree_files ${PREFIX:-.} $commit && ret=0 ;; esac + + return ret } (( $+functions[_git-revert] )) || @@ -1196,12 +1251,12 @@ _git-revert () { '(-e --edit)--no-edit[do not edit the commit message]' \ '(-n --no-commit)'{-n,--no-commit}'[do not commit the reversion]' \ '(-s --signoff)'{-s,--signoff}'[add Signed-off-by line at the end of the commit message]' \ - ': :__git_commits' && ret=0 + ': :__git_commits' } (( $+functions[_git-rm] )) || _git-rm () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -w -C -S -s \ @@ -1222,11 +1277,13 @@ _git-rm () { fi ;; esac + + return ret } (( $+functions[_git-shortlog] )) || _git-shortlog () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args local -a revision_options @@ -1258,11 +1315,13 @@ _git-shortlog () { fi ;; esac + + return ret } (( $+functions[_git-show] )) || _git-show () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 typeset -A opt_args local -a log_options revision_options @@ -1283,11 +1342,13 @@ _git-show () { 'blobs::__git_blobs' && ret=0 ;; esac + + return ret } (( $+functions[_git-stash] )) || _git-stash () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -C \ @@ -1368,6 +1429,8 @@ _git-stash () { esac ;; esac + + return ret } (( $+functions[_git-status] )) || @@ -1387,12 +1450,12 @@ _git-status () { all\:"also show untracked files in untracked directories (default)"))' \ '--ignore-submodules[ignore changes to submodules]:: :__git_ignore_submodules_whens' \ '(--porcelain)-z[use NUL termination on output]' \ - '*: :__git_ignore_line_inside_arguments _files' && ret=0 + '*: :__git_ignore_line_inside_arguments _files' } (( $+functions[_git-submodule] )) || _git-submodule () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -C -A '-*' \ @@ -1493,6 +1556,8 @@ _git-submodule () { esac ;; esac + + return ret } (( $+functions[_git-tag] )) || @@ -1524,7 +1589,17 @@ _git-tag () { '::pattern' \ - verification \ '-v[verifies gpg signutare of tags]' \ - '*:: :__git_ignore_line_inside_arguments __git_tags' && ret=0 + '*:: :__git_ignore_line_inside_arguments __git_tags' +} + +(( $+functions[_gitk] )) || +_gitk () { + _git-log +} + +(( $+functions[_tig] )) || +_tig () { + _git-log } # Ancillary Commands (Manipulators) @@ -1532,7 +1607,7 @@ _git-tag () { (( $+functions[_git-config] )) || _git-config () { local name_arg value_arg - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args if (( words[(I)--get-regexp] )); then @@ -1955,7 +2030,7 @@ _git-config () { case $state in (section) - __git_config_sections -b '(|)' '^' section-names 'section name' $* + __git_config_sections -b '(|)' '^' section-names 'section name' $* && ret=0 ;; (is-a-tty) declare -a values @@ -1963,7 +2038,7 @@ _git-config () { true false auto) - _describe -t values 'stdout is a tty' values + _describe -t values 'stdout is a tty' values && ret=0 ;; (option) local label=option @@ -2054,7 +2129,7 @@ _git-config () { __git_mergetools -S . && ret=0 ;; (pager.) - __git_aliases_and_commands && ret=0 + _git_commands && ret=0 ;; (pretty.) __git_config_sections -a '(|)' '^pretty\..+\.[^.]+$' prettys 'pretty format string' && ret=0 @@ -2145,7 +2220,7 @@ _git-config () { ;; (gettable-option) _describe -t git-options option \ - ${${${(0)"$(_call_program gettable-options git config -z --list)"}%%$'\n'*}//:/\\:} + ${${${(0)"$(_call_program gettable-options git config -z --list)"}%%$'\n'*}//:/\\:} && ret=0 ;; (gettable-colorbool-option) __git_config_sections -b '(|)' -a '(|)' '^color\.[^.]+$' gettable-colorbool-options option && ret=0 @@ -2178,7 +2253,7 @@ _git-config () { # TODO: Should really only complete unique remotes, that is, not the same # remote more than once in the list. __git_remotes -S $suffix -q && ret=0 - return + return ret ;; esac local z=$'\0' @@ -2187,7 +2262,7 @@ _git-config () { if (( $#parts < 2 )) && [[ $line[1] == [^.]##.*.[^.]## ]]; then parts=("${(S@0)${git_options_static[(r)(#i)${line[1]%%.*}.\*.${line[1]##*.}:*]}//(#b)(*[^\\]|):/$match[1]$z}") fi - (( $#parts > 0 )) || return + (( $#parts > 0 )) || return ret case $parts[4] in ('->'*) case ${parts[4]#->} in @@ -2453,6 +2528,8 @@ _git-config () { esac ;; esac + + return ret } (( $+functions[_git-fast-export] )) || @@ -2474,7 +2551,7 @@ _git-fast-export () { '--fake-missing-tagger=[fake a tagger when tags lack them]' \ '--no-data[do not output blocb objects, instead referring to them via their SHA-1 hash]' \ '--full-tree[output full tree for each commit]' \ - '*: :__git_commit_ranges' && ret=0 + '*: :__git_commit_ranges' } (( $+functions[_git-fast-import] )) || @@ -2494,7 +2571,7 @@ _git-fast-import () { '*--no-relative-marks[paths for export/import are not relative to internal directory in current repository]' \ '--export-pack-edges=-[list packfiles and last commit on branches in them in given file]: :_files' \ '--quiet[disable all non-fatal output]' \ - '--stats[display statistics about object created]' && ret=0 + '--stats[display statistics about object created]' } (( $+functions[_git-filter-branch] )) || @@ -2516,7 +2593,7 @@ _git-filter-branch () { '--original[namespace where original commits will be stored]:namespace:_directories' \ '-d[temporary directory used for rewriting]: :_directories' \ '(-f --force)'{-f,--force}'[force operation]' \ - '*: :__git_commit_ranges' && ret=0 + '*: :__git_commit_ranges' } (( $+functions[_git-mergetool] )) || @@ -2526,7 +2603,7 @@ _git-mergetool () { '(-t --tool)'{-t,--tool=}'[merge resolution program to use]: :__git_mergetools' \ '(-y --no-prompt --prompt)'{-y,--no-prompt}'[do not prompt before invocation of merge resolution program]' \ '(-y --no-prompt)--prompt[prompt before invocation of merge resolution program]' \ - '*:conflicted file:_files' && ret=0 + '*:conflicted file:_files' } (( $+functions[_git-pack-refs] )) || @@ -2535,7 +2612,7 @@ _git-pack-refs () { '( --no-all)--all[pack all refs]' \ '(--all )--no-all[do not pack all refs]' \ '( --no-prune)--prune[remove loose refs after packing them]' \ - '(--prune )--no-prune[do not remove loose refs after packing them]' && ret=0 + '(--prune )--no-prune[do not remove loose refs after packing them]' } (( $+functions[_git-prune] )) || @@ -2544,7 +2621,7 @@ _git-prune () { '(-n --dry-run)'{-n,--dry-run}'[do not remove anything; just report what would be removed]' \ '(-v --verbose)'{-v,--rerbose}'[report all removed objects]' \ '--expire[only expire loose objects older than given date]: :__git_datetimes' \ - '*:: :__git_heads' && ret=0 + '*:: :__git_heads' } (( $+functions[_git-reflog] )) || @@ -2555,9 +2632,9 @@ _git-reflog () { if [[ $words[2] == --* ]]; then _arguments -S \ $revision_options \ - ':: :__git_references' && ret=0 + ':: :__git_references' else - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args # TODO: -h is undocumented. @@ -2616,6 +2693,8 @@ _git-reflog () { ;; esac esac + + return ret fi } @@ -2627,12 +2706,12 @@ _git-relink () { '--help[display help]' \ ': :_directories' \ ': :_directories' \ - '*: :_directories' && ret=0 + '*: :_directories' } (( $+functions[_git-remote] )) || _git-remote () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -C \ @@ -2725,6 +2804,8 @@ _git-remote () { esac ;; esac + + return ret } (( $+functions[_git-repack] )) || @@ -2742,7 +2823,7 @@ _git-repack () { '--window=-[number of objects to consider when doing delta compression]: :__git_guard_number "number of objects"' \ '--depth=-[maximum delta depth]: :__git_guard_number "maximum delta depth"' \ '--window-memory=-[scale window size dynamically to not use more than N bytes of memory]: :__git_guard_bytes' \ - '--max-pack-size=-[maximum size of each output packfile]:maximum pack size:__git_guard_bytes' && ret=0 + '--max-pack-size=-[maximum size of each output packfile]:maximum pack size:__git_guard_bytes' } (( $+functions[_git-replace] )) || @@ -2753,14 +2834,14 @@ _git-replace () { '(- : *)-l[list replace refs]:pattern' \ ': :__git_objects' \ ':replacement:__git_objects' \ - '*: :__git_objects' && ret=0 + '*: :__git_objects' } # Ancillary Commands (Interrogators) (( $+functions[_git-blame] )) || _git-blame () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args declare -a revision_options @@ -2804,6 +2885,8 @@ _git-blame () { fi ;; esac + + return ret } (( $+functions[_git-cherry] )) || @@ -2814,13 +2897,13 @@ _git-cherry () { '--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length' \ ':upstream commit:__git_commits' \ '::head commit:__git_commits' \ - '::limit commit:__git_commits' && ret=0 + '::limit commit:__git_commits' } (( $+functions[_git-count-objects] )) || _git-count-objects () { _arguments \ - '(-v --verbose)'{-v,--verbose}'[also report number of in-pack objects and objects that can be removed]' && ret=0 + '(-v --verbose)'{-v,--verbose}'[also report number of in-pack objects and objects that can be removed]' } (( $+functions[_git-difftool] )) || @@ -2847,7 +2930,7 @@ _git-fsck () { '--strict[do strict checking]' \ '(-v --verbose)'{-v,--verbose}'[output additional information]' \ '--lost-found[write dangling objects into .git/lost-found]' \ - '*: :__git_objects' && ret=0 + '*: :__git_objects' } (( $+functions[_git-get-tar-commit-id] )) || @@ -2862,12 +2945,12 @@ _git-help () { '(-a --all -m --man -w --web)'{-i,--info}'[show all available commands]' \ '(-a --all -i --info -w --web)'{-m,--man}'[show all available commands]' \ '(-a --all -i --info -m --man )'{-w,--web}'[show all available commands]' \ - ': :__git_aliases_and_commands' && ret=0 + ': :_git_commands' } (( $+functions[_git-instaweb] )) || _git-instaweb () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -w -C -S -s \ @@ -2893,6 +2976,8 @@ _git-instaweb () { _describe -t commands command commands && ret=0 ;; esac + + return ret } (( $+functions[_git-merge-tree] )) || @@ -2900,12 +2985,12 @@ _git-merge-tree () { _arguments \ ':base-tree:__git_tree_ishs' \ ':branch 1:__git_tree_ishs' \ - ':branch 2:__git_tree_ishs' && ret=0 + ':branch 2:__git_tree_ishs' } (( $+functions[_git-rerere] )) || _git-rerere () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args # TODO: --rerere-autoupdate is undocumented. @@ -2924,6 +3009,8 @@ _git-rerere () { 'gc[prune old records of conflicted merges]' && ret=0 ;; esac + + return ret } (( $+functions[_git-rev-parse] )) || @@ -2941,6 +3028,8 @@ _git-rev-parse () { quiet_opts=({-q,--quiet}'[do not output error messages]') fi + local ret=0 + if (( words[(I)--parseopt] )); then if (( words[(I)--] )); then _message 'argument' @@ -2991,11 +3080,13 @@ _git-rev-parse () { '(--until --before)'{--until=-,--before=-}'[show --min-age= parameter corresponding given date string]:datestring' \ '*: :__git_objects' && ret=0 fi + + return ret } (( $+functions[_git-show-branch] )) || _git-show-branch () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -w -C -S -s -A '-*' \ @@ -3031,6 +3122,8 @@ _git-show-branch () { fi ;; esac + + return ret } (( $+functions[_git-verify-tag] )) || @@ -3038,7 +3131,7 @@ _git-verify-tag () { # TODO: -v and --verbose are undocumented. _arguments -w -S -s \ '(-v --verbose)'{-v,--verbose}'[output additional information]' \ - '*: :__git_tags' && ret=0 + '*: :__git_tags' } (( $+functions[_git-whatchanged] )) || @@ -3049,7 +3142,7 @@ _git-whatchanged () { _arguments -S \ $revision_options \ '1:: :__git_commits' \ - '*: :__git_cached_files' && ret=0 + '*: :__git_cached_files' } # Interacting With Others @@ -3067,7 +3160,7 @@ _git-archimport () { '-D[attempt to import trees that have been merged from]: :__git_guard_number depth' \ '-a[auto-register archives at http://mirrors.sourcecontrol.net]' \ '-t[use given directory as temporary directory]: :_directories' \ - '*:archive/branch' && ret=0 + '*:archive/branch' } (( $+functions[_git-cvsexportcommit] )) || @@ -3088,7 +3181,7 @@ _git-cvsexportcommit () { '-v[verbose output]' \ '-h[display usage]' \ ':: :__git_commits' \ - ': :__git_commits' && ret=0 + ': :__git_commits' } (( $+functions[_git-cvsimport] )) || @@ -3115,7 +3208,7 @@ _git-cvsimport () { '-A[specify author-conversion file]:author-conversion file:_files' \ '-R[generate cvs-revisions file mapping CVS revision numbers to commit IDs]' \ '-h[display usage information]' \ - ':cvsmodule' && ret=0 + ':cvsmodule' } (( $+functions[_git-cvsserver] )) || @@ -3127,7 +3220,7 @@ _git-cvsserver () { '(- * -V --version)'{-V,--version}'[display version information]' \ '(- * -h --help)'{-h,-H,--help}'[display usage information]' \ '::type:(pserver server)' \ - '*: :_directories' && ret=0 + '*: :_directories' } (( $+functions[_git-imap-send] )) || @@ -3140,7 +3233,7 @@ _git-quiltimport () { _arguments -S \ '(-n --dry-run)'{-n,--dry-run}'[check patches and warn if they cannot be imported]' \ '--author[default author name and email address to use for patches]: :_email_addresses' \ - '--patches[set directory containing patches]:patch directory:_directories' && ret=0 + '--patches[set directory containing patches]:patch directory:_directories' } (( $+functions[_git-request-pull] )) || @@ -3190,12 +3283,12 @@ _git-send-email () { '( --no-validate)--validate[perform sanity checks on patches]' \ '(--validate )--validate[do not perform sanity checks on patches]' \ '--force[send emails even if safetiy checks would prevent it]' \ - '*: :_files' && ret=0 + '*: :_files' } (( $+functions[_git-svn] )) || _git-svn () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -C \ @@ -3438,6 +3531,8 @@ _git-svn () { esac ;; esac + + return ret } # LOW-LEVEL COMMANDS (PLUMBING) @@ -3468,7 +3563,7 @@ _git-apply () { '--inaccurate-eof[work around missing-new-line-at-EOF bugs]' \ '(-v --verbose)'{-v,--verbose}'[display progress on stderr]' \ '--recount[do not trust line counts in hunk headers]' \ - '*:patch:_files' && ret=0 + '*:patch:_files' } (( $+functions[_git-checkout-index] )) || @@ -3490,7 +3585,7 @@ _git-checkout-index () { '--temp[write content to temporary files]' \ '(-a --all *)--stdin[read list of paths from the standard input]' \ $z_opt \ - '*: :__git_cached_files' && ret=0 + '*: :__git_cached_files' } (( $+functions[_git-commit-tree] )) || @@ -3498,11 +3593,11 @@ _git-commit-tree () { if (( CURRENT == 2 )); then _arguments \ '-h[display usage]' \ - ': :__git_trees' && ret=0 + ': :__git_trees' elif [[ $words[CURRENT-1] == -p ]]; then local expl _description commits expl 'parent commit' - __git_objects $expl && ret=0 + __git_objects $expl else compadd - '-p' fi @@ -3520,7 +3615,7 @@ _git-hash-object () { '(: --stdin --path)--stdin-paths[read file names from standard input instead of from command line]' \ '( --no-filters)--path=[hash object as if it were located at given path]: :_files' \ '(--path )--no-filters[hash contents as is, ignoring any input filters]' \ - '(--stdin --stdin-paths):file:_files' && ret=0 + '(--stdin --stdin-paths):file:_files' } (( $+functions[_git-index-pack] )) || @@ -3541,7 +3636,7 @@ _git-index-pack () { '--stdin[read pack from stdin and instead write to specified file]' \ $stdin_opts \ '--strict[die if the pack contains broken objects or links]' \ - ':pack file:_files -g "*.pack"' && ret=0 + ':pack file:_files -g "*.pack"' } (( $+functions[_git-merge-file] )) || @@ -3570,7 +3665,7 @@ _git-merge-file () { '--diff3[undocumented]' \ ':current file:_files' \ ':base file:_files' \ - ':other file:_files' && ret=0 + ':other file:_files' } (( $+functions[_git-merge-index] )) || @@ -3578,7 +3673,7 @@ _git-merge-index () { if (( CURRENT > 2 )) && [[ $words[CURRENT-1] != -[oq] ]]; then _arguments -S \ '(:)-a[run merge against all files in index that need merging]' \ - '*: :__git_cached_files' && ret=0 + '*: :__git_cached_files' else declare -a arguments @@ -3586,7 +3681,7 @@ _git-merge-index () { (( CURRENT == 2 || CURRENT == 3 )) && arguments+='(-o)-q[do not complain about failed merges]' (( 2 <= CURRENT && CURRENT <= 4 )) && arguments+='*:merge program:_files -g "*(*)"' - _arguments -S $arguments && ret=0 + _arguments -S $arguments fi } @@ -3600,7 +3695,7 @@ _git-mktree () { _arguments -w -S -s \ '-z[read NUL-terminated ls-tree -z output]' \ '--missing[allow missing objects]' \ - '--batch[allow creation of more than one tree]' && ret=0 + '--batch[allow creation of more than one tree]' } (( $+functions[_git-pack-objects] )) || @@ -3642,14 +3737,14 @@ _git-pack-objects () { '--keep-true-parents[pack parents hidden by grafts]' \ '( --unpack-unreachable)--keep-unreachable[undocumented]' \ '(--keep-unreachable )--unpack-unreachable[undocumented]' \ - ':base-name:_files' && ret=0 + ':base-name:_files' } (( $+functions[_git-prune-packed] )) || _git-prune-packed () { _arguments -w -S -s \ '(-n --dry-run)'{-n,--dry-run}'[only list objects that would be removed]' \ - '(-q --quiet)'{-q,--quiet}'[do not display progress on standard error]' && ret=0 + '(-q --quiet)'{-q,--quiet}'[do not display progress on standard error]' } (( $+functions[_git-read-tree] )) || @@ -3688,7 +3783,7 @@ _git-read-tree () { '--no-sparse-checkout[display sparse checkout support]' \ '1:first tree-ish to be read/merged:__git_tree_ishs' \ '2::second tree-ish to be read/merged:__git_tree_ishs' \ - '3::third tree-ish to be read/merged:__git_tree_ishs' && ret=0 + '3::third tree-ish to be read/merged:__git_tree_ishs' } (( $+functions[_git-symbolic-ref] )) || @@ -3697,7 +3792,7 @@ _git-symbolic-ref () { '(-q --quiet)'{-q,--quiet}'[do not issue error if specified name is not a symbolic ref]' \ '-m[update reflog for specified name with specied reason]:reason for update' \ ':symbolic reference:__git_heads' \ - ':: :__git_references' && ret=0 + ':: :__git_references' } (( $+functions[_git-unpack-objects] )) || @@ -3706,7 +3801,7 @@ _git-unpack-objects () { '-n[only list the objects that would be unpacked]' \ '-q[run quietly]' \ '-r[try recovering objects from corrupt packs]' \ - '--strict[do not write objects with broken content or links]' && ret=0 + '--strict[do not write objects with broken content or links]' } (( $+functions[_git-update-index] )) || @@ -3744,7 +3839,7 @@ _git-update-index () { '(: -)--stdin[read list of paths from standard input]' \ '--verbose[report what is being added and removed from the index]' \ $z_opt \ - '*:: :_files' && ret=0 + '*:: :_files' } (( $+functions[_git-update-ref] )) || @@ -3755,7 +3850,7 @@ _git-update-ref () { '--no-deref[overwrite ref itself, not what it points to]' \ ':symbolic reference:__git_revisions' \ ':new reference:__git_revisions' \ - '::old reference:__git_revisions' && ret=0 + '::old reference:__git_revisions' } (( $+functions[_git-write-tree] )) || @@ -3763,7 +3858,7 @@ _git-write-tree () { # NOTE: --ignore-cache-tree is only used for debugging. _arguments -w -S -s \ '--missing-ok[ignore objects in index that are missing in object database]' \ - '--prefix=[write tree representing given sub-directory]:sub-directory:_directories -r ""' && ret=0 + '--prefix=[write tree representing given sub-directory]:sub-directory:_directories -r ""' } # Interrogation commands @@ -3779,7 +3874,7 @@ _git-cat-file () { '(- :)--batch[print SHA1, type, size, and contents of each object provided on stdin]' \ '(- :)--batch-check[print SHA1, type, and size of each object provided on stdin]' \ '(-):object type:(blob commit tag tree)' \ - ': :__git_objects' && ret=0 + ': :__git_objects' } (( $+functions[_git-diff-files] )) || @@ -3791,7 +3886,7 @@ _git-diff-files () { $revision_options \ ': :__git_changed-in-working-tree_files' \ ': :__git_changed-in-working-tree_files' \ - '*: :__git_changed-in-working-tree_files' && ret=0 + '*: :__git_changed-in-working-tree_files' } (( $+functions[_git-diff-index] )) || @@ -3808,12 +3903,12 @@ _git-diff-index () { '--cached[do not consider the work tree at all]' \ '-m[flag non-checked-out files as up-to-date]' \ ': :__git_tree_ishs' \ - '*: :__git_cached_files' && ret=0 + '*: :__git_cached_files' } (( $+functions[_git-diff-tree] )) || _git-diff-tree () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args declare -a revision_options @@ -3858,6 +3953,8 @@ _git-diff-tree () { fi ;; esac + + return ret } (( $+functions[_git-for-each-ref] )) || @@ -3873,7 +3970,7 @@ _git-for-each-ref () { '(-s --shell -p --perl --python --tcl)'{-p,--perl}'[use string literals suitable for Perl]' \ '(-s --shell -p --perl --tcl)'--python'[use string literals suitable for Python]' \ '(-s --shell -p --perl --python )'--tcl'[use string literals suitable for Tcl]' \ - ':: :_guard "([^-]?#|)" pattern' && ret=0 + ':: :_guard "([^-]?#|)" pattern' } (( $+functions[_git-ls-files] )) || @@ -3908,7 +4005,7 @@ _git-ls-files () { '-v[identify each files status (hmrck?)]' \ '--full-name[force paths to be output relative to the project top directory]' \ '--abbrev=[set minimum SHA1 display-length]: :__git_guard_number length' \ - '*:: :_files' && ret=0 + '*:: :_files' } (( $+functions[_git-ls-remote] )) || @@ -3919,12 +4016,12 @@ _git-ls-remote () { '(-t --tags)'{-t,--tags}'[show only refs under refs/tags]' \ '(-u --upload-pack)'{-u,--upload-pack=-}'[specify path to git-upload-pack on remote side]:remote path' \ ': :__git_any_repositories' \ - '*: :__git_references' && ret=0 + '*: :__git_references' } (( $+functions[_git-ls-tree] )) || _git-ls-tree () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -w -C -S -s \ @@ -3945,6 +4042,8 @@ _git-ls-tree () { __git_ignore_line __git_tree_files ${PREFIX:-.} $line[1] && ret=0 ;; esac + + return ret } (( $+functions[_git-merge-base] )) || @@ -3954,7 +4053,7 @@ _git-merge-base () { '--octopus[compute best common ancestors of all supplied commits]' \ '(-)--independent[display minimal subset of supplied commits with same ancestors]' \ ': :__git_commits' \ - '*: :__git_commits' && ret=0 + '*: :__git_commits' } (( $+functions[_git-name-rev] )) || @@ -3967,7 +4066,7 @@ _git-name-rev () { '--name-only[display only name of commits]' \ '--no-undefined[die with non-zero return when a reference is undefined]' \ '--always[show uniquely abbreviated commit object as fallback]' \ - '(--stdin --all)*: :__git_commits' && ret=0 + '(--stdin --all)*: :__git_commits' } (( $+functions[_git-pack-redundant] )) || @@ -3976,12 +4075,12 @@ _git-pack-redundant () { '(:)--all[process all packs]' \ '--alt-odb[do not require objects to be present in local packs]' \ '--verbose[output some statistics to standard error]' \ - '(--all)*::packs:_files -g "*.pack"' && ret=0 + '(--all)*::packs:_files -g "*.pack"' } (( $+functions[_git-rev-list] )) || _git-rev-list () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args declare -a revision_options @@ -4008,6 +4107,8 @@ _git-rev-list () { fi ;; esac + + return ret } (( $+functions[_git-show-index] )) || @@ -4029,14 +4130,14 @@ _git-show-ref () { '(-q --quiet)'{-q,--quiet}'[do not print any results]' \ '*: :_guard "([^-]?#|)" pattern' \ - exclude \ - '--exclude-existing=-[filter out existing refs from stdin]:: :_guard "([^-]?#|)" pattern' && ret=0 + '--exclude-existing=-[filter out existing refs from stdin]:: :_guard "([^-]?#|)" pattern' } (( $+functions[_git-unpack-file] )) || _git-unpack-file () { _arguments -A '-*' \ '(:)-h[display usage information]' \ - '(-): :__git_blobs' && ret=0 + '(-): :__git_blobs' } (( $+functions[_git-var] )) || @@ -4046,7 +4147,7 @@ _git-var () { '(-):variable:((GIT_AUTHOR_IDENT\:"name and email of author" \ GIT_COMMITTER_IDENT\:"name and email of committer" \ GIT_EDITOR\:"text editor used by git commands" \ - GIT_PAGER\:"text viewer used by git commands"))' && ret=0 + GIT_PAGER\:"text viewer used by git commands"))' } (( $+functions[_git-verify-pack] )) || @@ -4054,7 +4155,7 @@ _git-verify-pack () { _arguments -w -S -s \ '(-v --verbose)'{-v,--verbose}'[show objects contained in pack]' \ '(-s --stat-only)'{-s,--stat-only}'[do not verify pack contents; only display histogram of delta chain length]' \ - '*:index file:_files -g "*.idx"' && ret=0 + '*:index file:_files -g "*.idx"' } # Synching Repositories @@ -4088,7 +4189,7 @@ _git-daemon () { '--disable=-[disable site-wide service]: :__git_daemon_service' \ '--allow-override[allow overriding site-wide service]: :__git_daemon_service' \ '--forbid-override[forbid overriding site-wide service]: :__git_daemon_service' \ - '*:repository:_directories' && ret=0 + '*:repository:_directories' } (( $+functions[_git-fetch-pack] )) || @@ -4105,7 +4206,7 @@ _git-fetch-pack () { '--no-progress[do not display progress]' \ '-v[produce verbose output]' \ ': :__git_any_repositories' \ - '*: :__git_references' && ret=0 + '*: :__git_references' } (( $+functions[_git-http-backend] )) || @@ -4129,13 +4230,13 @@ _git-send-pack () { '--stateless-rpc[undocumented]' \ '--helper-status[undocumented]' \ ': :__git_any_repositories' \ - '*: :__git_remote_references' && ret=0 + '*: :__git_remote_references' } (( $+functions[_git-update-server-info] )) || _git-update-server-info () { _arguments -w -S -s \ - '(-f --force)'{-f,--force}'[update the info files from scratch]' && ret=0 + '(-f --force)'{-f,--force}'[update the info files from scratch]' } (( $+functions[_git-http-fetch] )) || @@ -4149,7 +4250,7 @@ _git-http-fetch () { '--recover[recover from a failed fetch]' \ '(1)--stdin[read commit ids and refs from standard input]' \ ': :__git_commits' \ - ': :_urls' && ret=0 + ': :_urls' } (( $+functions[_git-http-push] )) || @@ -4162,7 +4263,7 @@ _git-http-push () { '( -D)-d[remove refs from remote repository]' \ '(-d )-D[forcefully remove refs from remote repository]' \ ': :_urls' \ - '*: :__git_remote_references' && ret=0 + '*: :__git_remote_references' } # NOTE: git-parse-remote isn’t a user command. @@ -4174,12 +4275,12 @@ _git-receive-pack () { _arguments -A '-*' \ '--advertise-refs[undocumented]' \ '--stateless-rpc[undocumented]' \ - ':directory to sync into:_directories' && ret=0 + ':directory to sync into:_directories' } (( $+functions[_git-shell] )) || _git-shell () { - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args _arguments -C \ @@ -4217,13 +4318,15 @@ _git-shell () { esac ;; esac + + return ret } (( $+functions[_git-upload-archive] )) || _git-upload-archive () { _arguments \ - ':directory to get tar archive from:_directories' && ret=0 + ':directory to get tar archive from:_directories' } (( $+functions[_git-upload-pack] )) || @@ -4235,7 +4338,7 @@ _git-upload-pack () { '--timeout=-[interrupt transfer after given number of seconds of inactivity]: :__git_guard_number "inactivity timeout"' \ '--advertise-refs[undocumented]' \ '--stateless-rpc[undocumented]' \ - ': :_directories' && ret=0 + ': :_directories' } # Internal Helper Commands @@ -4244,7 +4347,7 @@ _git-upload-pack () { _git-check-attr () { local z_opt= - local curcontext=$curcontext state line + local curcontext=$curcontext state line ret=1 declare -A opt_args if (( words[(I)--stdin] )); then @@ -4280,6 +4383,8 @@ _git-check-attr () { fi ;; esac + + return ret } (( $+functions[_git-check-ref-format] )) || @@ -4288,7 +4393,7 @@ _git-check-ref-format () { '-h[display usage information]' \ '--print[display canonicalized name of hypothetical reference of given name]' \ '--branch[expand previous branch syntax]' \ - ': :__git_references' && ret=0 + ': :__git_references' } (( $+functions[_git-fmt-merge-msg] )) || @@ -4297,7 +4402,7 @@ _git-fmt-merge-msg () { '( --no-log)--log[display one-line descriptions from actual commits being merged]' \ '(--log )--no-log[do not display one-line descriptions from actual commits being merged]' \ '(-m --message)'{-m+,--message=}'[use given message instead of branch names for first line in log message]:message' \ - '(-F --file)'{-F,--file}'[specify list of merged objects from file]: :_files' && ret=0 + '(-F --file)'{-F,--file}'[specify list of merged objects from file]: :_files' } (( $+functions[_git-mailinfo] )) || @@ -4312,7 +4417,7 @@ _git-mailinfo () { '(--scissors )--no-scissors[do not remove everything in body before a scissors line]' \ '--no-inbody-headers[undocumented]' \ ':message file:_files' \ - ':patch file:_files' && ret=0 + ':patch file:_files' } (( $+functions[_git-mailsplit] )) || @@ -4323,7 +4428,7 @@ _git-mailsplit () { '-d-[specify number of leading zeros]: :__git_guard_number precision' \ '-f-[skip the first N numbers]: :__git_guard_number' \ '--keep-cr[do not remove CR from lines ending with CR+LF]' \ - '*::mbox file:_files' && ret=0 + '*::mbox file:_files' } (( $+functions[_git-merge-one-file] )) || @@ -4341,7 +4446,7 @@ _git-patch-id () { (( $+functions[_git-stripspace] )) || _git-stripspace () { _arguments \ - '(-s --strip-comments)'{-s,--strip-comments}'[also strip lines starting with #]' && ret=0 + '(-s --strip-comments)'{-s,--strip-comments}'[also strip lines starting with #]' } # INTERNAL GIT COMPLETION FUNCTIONS @@ -4432,7 +4537,11 @@ __git_ignore_line () { (( $+functions[__git_ignore_line_inside_arguments] )) || __git_ignore_line_inside_arguments () { - __git_ignore_line ${*[-1]} ${*[1,-2]} + declare -a compadd_opts + + zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F: + + __git_ignore_line $* $compadd_opts } # Common Argument Types @@ -4591,10 +4700,41 @@ _git_commands () { patch-id:'compute unique ID for a patch' stripspace:'filter out empty lines') + local -a user_commands + zstyle -a :completion:$curcontext: user-commands user_commands + + local -a third_party_commands + local command + for command in $_git_third_party_commands; do + (( $+commands[git-${command%%:*}] )) && third_party_commands+=$command + done + + local -a aliases unique_aliases + __git_extract_aliases + local alias + for alias in $aliases; do + local name=${alias%%:*} + (( main_porcelain_commands[(I)$name:*] || + user_commands[(I)$name:*] || + third_party_commands[(I)$name:*] || + ancillary_manipulator_commands[(I)$name:*] || + ancillary_interrogator_commands[(I)$name:*] || + interaction_commands[(I)$name:*] || + plumbing_manipulator_commands[(I)$name:*] || + plumbing_interrogator_commands[(I)$name:*] || + plumbing_sync_commands[(I)$name:*] || + plumbing_sync_helper_commands[(I)$name:*] || + plumbing_internal_helper_commands[(I)$name:*] )) || unique_aliases+=$alias + done + integer ret=1 - # TODO: Is this the correct way of doing it? - # TODO: Should we be chaining them together with || instead? + + # 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 @@ -4603,24 +4743,23 @@ _git_commands () { _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 + return ret } (( $+functions[__git_aliases] )) || __git_aliases () { - declare -a aliases - - aliases=(${^${${(0)"$(_call_program aliases "git config -z --get-regexp '^alias.'")"}#alias.}/$'\n'/:alias for \'}\') + local -a aliases + __git_extract_aliases _describe -t aliases alias aliases $* } -(( $+functions[__git_aliases_and_commands] )) || -__git_aliases_and_commands () { - _alternative \ - 'aliases::__git_aliases' \ - 'commands::_git_commands' +(( $+functions[__git_extract_aliases] )) || +__git_extract_aliases () { + aliases=(${^${${(0)"$(_call_program aliases "git config -z --get-regexp '^alias.'")"}#alias.}/$'\n'/:alias for \'}\') } + (( $+functions[__git_date_formats] )) || __git_date_formats () { declare -a date_formats @@ -4651,7 +4790,7 @@ __git_merge_strategies () { 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 + __git_command_successful $pipestatus || return 1 _wanted merge-strategies expl 'merge strategy' compadd $* - $merge_strategies } @@ -4815,7 +4954,7 @@ __git_reflog_entries () { declare -a reflog_entries reflog_entries=(${${${(f)"$(_call_program reflog-entries git reflog 2>/dev/null)"}#* }%%:*}) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 if compset -P '*@'; then reflog_entries=(${${(M)reflog_entries:#$IPREFIX*}#$IPREFIX}) @@ -4876,7 +5015,7 @@ __git_stashes () { declare -a stashes stashes=(${${(f)"$(_call_program stashes git stash list 2>/dev/null)"}/: */}) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 _wanted stashes expl stash compadd $* - $stashes } @@ -4915,7 +5054,7 @@ __git_branch_names () { declare -a 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 + __git_command_successful $pipestatus || return 1 _wanted branch-names expl branch-name compadd $* - $branch_names } @@ -4926,7 +5065,7 @@ __git_remote_branch_names () { declare -a 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 + __git_command_successful $pipestatus || return 1 _wanted remote-branch-names expl 'remote branch name' compadd $* - $branch_names } @@ -5046,7 +5185,7 @@ __git_submodules () { declare -a submodules submodules=(${${(f)"$(_call_program submodules git submodule 2>/dev/null)"}#* }) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 _wanted submodules expl submodule compadd $* - $submodules } @@ -5059,7 +5198,7 @@ __git_tags () { declare -a tags tags=(${${(f)"$(_call_program tagrefs git for-each-ref --format='"%(refname)"' refs/tags 2>/dev/null)"}#refs/tags/}) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 _wanted tags expl tag compadd $* - $tags } @@ -5082,15 +5221,11 @@ __git_tags_of_type () { type=$1; shift 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 + __git_command_successful $pipestatus || return 1 _wanted $type-tags expl "$type tag" compadd $* - $tags } -(( $+functions[__git_tag_ids] )) || -__git_tag_ids () { -} - # Reference Argument Types (( $+functions[__git_references] )) || @@ -5107,7 +5242,7 @@ __git_references () { # TODO: deal with GIT_DIR if [[ $_git_refs_cache_pwd != $PWD ]]; then _git_refs_cache=(${${${(f)"$(_call_program references git ls-remote ./. 2>/dev/null)"}#*$'\t'}#refs/(heads|tags)/}) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 _git_refs_cache_pwd=$PWD fi @@ -5120,7 +5255,7 @@ __git_local_references () { if [[ $_git_local_refs_cache_pwd != $PWD ]]; then _git_local_refs_cache=(${${${(f)"$(_call_program references git ls-remote ./. 2>/dev/null)"}#*$'\t'}#refs/}) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 _git_local_refs_cache_pwd=$PWD fi @@ -5137,7 +5272,7 @@ __git_local_references () { local references expl references=(${${(M)${${(f)"$(_call_program references git ls-remote ./. 2>/dev/null)"}#*$'\t'}:#refs/notes/*}#refs/notes/}) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 _wanted references expl reference compadd - $references } @@ -5147,9 +5282,9 @@ __git_notes_refs () { declare -a 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 + __git_command_successful $pipestatus || return 1 - _wanted notes-refs expl "notes ref" compadd $* - $notes_refs + _wanted notes-refs expl 'notes ref' compadd $* - $notes_refs } # File Argument Types @@ -5159,7 +5294,7 @@ __git_files_relative () { local files file f_parts prefix p_parts tmp prefix=$(_call_program gitprefix git rev-parse --show-prefix 2>/dev/null) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 if (( $#prefix == 0 )); then print $1 @@ -5196,10 +5331,10 @@ __git_files () { tag=$1 description=$2; shift 2 gitcdup=$(_call_program gitcdup git rev-parse --show-cdup 2>/dev/null) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 gitprefix=$(_call_program gitprefix git rev-parse --show-prefix 2>/dev/null) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 # TODO: --directory should probably be added to $opts when --others is given. @@ -5207,6 +5342,7 @@ __git_files () { files=(${(0)"$(_call_program files git ls-files -z --exclude-standard $opts -- ${pref:+$pref\*} 2>/dev/null)"}) __git_command_successful $pipestatus || return +# _wanted $tag expl $description _files -g '{'${(j:,:)files}'}' $compadd_opts - _wanted $tag expl $description _multi_parts -f $compadd_opts - / files } @@ -5255,9 +5391,9 @@ __git_changed-in-index_files () { local files expl files=$(_call_program files git diff-index -z --name-only --no-color --cached HEAD 2>/dev/null) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 files=(${(0)"$(__git_files_relative $files)"}) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 _wanted changed-in-index-files expl 'changed in index file' _multi_parts $@ - / files } @@ -5267,9 +5403,9 @@ __git_changed-in-working-tree_files () { local files expl files=$(_call_program changed-in-working-tree-files git diff -z --name-only --no-color 2>/dev/null) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 files=(${(0)"$(__git_files_relative $files)"}) - __git_command_successful $pipestatus || return + __git_command_successful $pipestatus || return 1 _wanted changed-in-working-tree-files expl 'changed in working tree file' _multi_parts $@ -f - / files } @@ -5309,7 +5445,7 @@ __git_tree_files () { # Repository Argument Types # _remote_files -_remote_files () { +_remote_files_git () { # FIXME: these should be imported from _ssh # TODO: this should take -/ to only get directories # There should be coloring based on all the different ls -F classifiers. @@ -5348,7 +5484,7 @@ __git_remote_repositories () { service= _ssh if compset -P '*:'; then - _remote_files + _remote_files_git else _ssh_hosts -S: fi @@ -5410,7 +5546,7 @@ __git_guard_branch-name () { __git_guard_diff-stat-width () { if [[ $PREFIX == *,* ]]; then compset -P '*,' - __git_guard_number "filename width" + __git_guard_number 'filename width' else compset -S ',*' __git_guard_number width @@ -5423,7 +5559,7 @@ __git_guard_number () { zparseopts -K -D -A opts M: J: V: 1 2 n F: X: - _guard "[[:digit:]]#" ${1:-number} + _guard '[[:digit:]]#' ${1:-number} } (( $+functions[__git_guard_bytes] )) || @@ -5434,17 +5570,17 @@ __git_guard_bytes () { (( $+functions[__git_datetimes] )) || __git_datetimes () { # TODO: Use this in more places. - _guard "*" 'time specification' + _guard '*' 'time specification' } (( $+functions[__git_stages] )) || __git_stages () { - __git_guard $* "[[:digit:]]#" 'stage' + __git_guard $* '[[:digit:]]#' 'stage' } (( $+functions[__git_svn_revision_numbers] )) || __git_svn_revision_numbers () { - __git_guard_number "revision number" + __git_guard_number 'revision number' } # _arguments Helpers @@ -5960,16 +6096,6 @@ __git_color_attributes () { _describe -t attributes attribute attributes $* } -(( $+functions[_gitk] )) || -_gitk () { - _git-log -} - -(( $+functions[_tig] )) || -_tig () { - _git-log -} - # Now, for the main driver… _git() { if (( CURRENT > 2 )); then @@ -5979,7 +6105,7 @@ _git() { aliases=(${(f)${${${(f)"$(_call_program aliases git config --get-regexp '\^alias\.')"}#alias.}/ /$'\n'}/(#e)/$'\n'}) (( $#aliases % 2 == 0 )) && git_aliases=($aliases) - if [[ -n ${git_aliases[$words[2]]} ]] ; then + if (( $+git_aliases[$words[2]] && !$+commands[git-$words[2]] )); then local -a tmpwords expalias expalias=(${(z)git_aliases[$words[2]]}) tmpwords=(${words[1]} ${expalias}) @@ -5995,7 +6121,8 @@ _git() { unset git_aliases aliases fi - local ret=1 + integer ret=1 + if [[ $service == git ]]; then local curcontext=$curcontext state line declare -A opt_args @@ -6016,20 +6143,54 @@ _git() { '--no-replace-objects[do not use replacement refs to replace git objects]' \ '(-): :->command' \ '(-)*:: :->option-or-argument' && return + case $state in (command) - __git_aliases_and_commands && ret=0 + _git_commands && ret=0 ;; (option-or-argument) curcontext=${curcontext%:*:*}:git-$words[1]: - _call_function ret _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' + fi ;; esac else _call_function ret _$service fi + return ret } +# Load any _git-* definitions so that they may be completed as commands. +declare -gUa _git_third_party_commands +_git_third_party_commands=() + +local file +for file in ${^fpath}/_git-*~(*~|*.zwc)(.N); do + local name=${${file:t}#_git-} + if (( $+_git_third_party_commands[$name] )); then + continue + fi + + local desc= + integer i=1 + while read input; do + if (( i == 2 )); then + if [[ $input == '#description '* ]]; then + desc=:${input#\#description } + fi + break + fi + (( i++ )) + done < $file + + _git_third_party_commands+=$name$desc +done + _git diff --git a/Completion/Unix/Command/_iconv b/Completion/Unix/Command/_iconv index 2cd69b21a..75fe521ee 100644 --- a/Completion/Unix/Command/_iconv +++ b/Completion/Unix/Command/_iconv @@ -21,7 +21,7 @@ if _pick_variant gnu=GNU unix --version; then '1:input file:_files' && return 0 if [[ $state = codeset ]]; then - if compset -P '*/'; then + if compset -P '*[^/]/'; then _wanted option expl option compadd "$@" /TRANSLIT && ret=0 else _wanted codesets expl 'code set' compadd "$@" \ diff --git a/Completion/Unix/Command/_initctl b/Completion/Unix/Command/_initctl index 11bd59b50..6505e4298 100644 --- a/Completion/Unix/Command/_initctl +++ b/Completion/Unix/Command/_initctl @@ -37,7 +37,7 @@ _initctl_fillarray_events_args () # list all upstart jobs, i.e. all files in /etc/init/ _initctl_helper_jobs() { - _path_files -W "/etc/init/" -g "*.conf(.:r)" + _path_files -W "/etc/init/" -g "*.conf(-.:r)" } # list events, generate array if necessary diff --git a/Completion/Unix/Command/_ln b/Completion/Unix/Command/_ln new file mode 100644 index 000000000..89b7177ab --- /dev/null +++ b/Completion/Unix/Command/_ln @@ -0,0 +1,76 @@ +#compdef ln gln + +local curcontext="$curcontext" state line ret=1 +local -A opt_args + +local -a args +args=( + '-f[remove existing destination files]' + '-s[create symbolic links instead of hard links]') + +local -a opts + +local variant +_pick_variant -r variant gnu=gnu unix --help +if [[ $variant == gnu ]]; then + opts=(-S) + args=( + '(-b --backup)-b[create a backup of each existing destination file]' \ + '(-b --backup)--backup=[create a backup of each existing destination file]::method:(( + none\:"never create backups" + off\:"never create backups" + numbered\:"create numbered backup" + t\:"create numbered backup" + existing\:"same as numbered if numbered backups exist, otherwise same as simple" + nil\:"same as numbered if numbered backups exist, otherwise same as simple" + simple\:"always create simple backups" + never\:"always create simple backups"))' + '(-d -F --directory)'{-d,-F,--directory}'[allow the superuser to attempt to hard link directories]' + '(-f --force)'{-f,--force}'[remove existing destination files]' + '(-i --interactive)'{-i,--interactive}'[prompt before removing destination files]' + '(-L --logical)'{-L,--logical}'[create hard links to symbolic link references]' + '(-n --no-dereference)'{-n,--no-dereference}'[treat destination symbolic link to a directory as if it were a normal file]' + '(-P --physical)'{-P,--physical}'[create hard links directly to symbolic links]' + '(-s --symbolic)'{-s,--symbolic}'[create symbolic links instead of hard links]' + '(-S --suffix)'{-S,--suffix=}'[override default backup suffix]:suffix' + '(-t --target-directory)'{-t,--target-directory=}'[specify directory in which to create the links]: :_directories' + '(-T --no-target-directory)'{-T,--no-target-directory}'[treat destination as a normal file]' + '(-v --verbose)'{-v,--verbose}'[print name of each linked file]' + '--help[display usage information and exit]' + '--version[display version information and exit]') +elif (( ${+builtins[ln]} )); then + args+=( + '-d[attempt to hard link directories]' + {-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]') +fi + +_arguments -s $opts \ + $args \ + ':link target:_files' \ + '*:: :->files' && ret=0 + +case $state in + (files) + if [[ $variant == gnu && -n ${opt_args[(I)-t|--target-directory]} ]]; then + _wanted files expl 'link target' _files && ret=0 + else + if (( CURRENT == 2 )); then + local expl + _wanted files expl 'additional link target or link name' _files && ret=0 + else + _alternative \ + 'link-targets:additional link target:_files' \ + 'target-directories:target directory:_directories' && ret=0 + fi + fi + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_lp b/Completion/Unix/Command/_lp index 5d46a75bb..e0654e711 100644 --- a/Completion/Unix/Command/_lp +++ b/Completion/Unix/Command/_lp @@ -1,9 +1,9 @@ -#compdef lp lpr lpq lprm lpoptions lpstat +#compdef lp lpr lpq lprm lpoptions lpstat lpinfo lpadmin _lp_get_printer() { - # No reason to call _lp_get_printer when service == lpstat. Others matched - # below. + # No reason to call _lp_get_printer when service == lpstat or lpinfo. Others + # matched below. case $service in (lpr|lpq|lprm) [[ "$words" == (#I)*-P* ]] && printer="${${words##*(#I)-P( |)}%% *}" @@ -11,6 +11,9 @@ _lp_get_printer() (lp) [[ "$words" == (#I)*-d* ]] && printer="${${words##*(#I)-d( |)}%% *}" ;; + (lpadmin) + [[ "$words" == (#I)*-p* ]] && printer="${${words##*(#I)-p( |)}%% *}" + ;; (lpoptions) [[ "$words" == (#I)*-(d|p)* ]] && \ printer="${${words##*(#I)-(d|p)( |)}%% *}" @@ -29,6 +32,13 @@ _lp_job_options() lopts_no_args=(fitplot landscape) + if [[ $service == 'lpadmin' ]]; then + # Extra options from lpadmin man page. + lopts_with_args+=(cupsIPPSupplies cupsSNMPSupplies job-k-limit + job-page-limit job-quota-period job-sheets-default name name-default + port-monitor printer-error-policy printer-is-shared printer-op-policy) + fi + _lp_get_printer [[ -n "$printer" ]] && printer=(-p $printer) @@ -53,6 +63,12 @@ _lp_job_options() (scaling|cpi|lpi|page-(bottom|left|right|top)) return 0; # Don't complete anything ;; + (cupsIPPSupplies|cupsSNMPSupplies|printer-is-shared) + compadd "$@" true false + ;; + (printer-error-policy) + compadd "$@" abort-job retry-job retry-current-job stop-printer + ;; (*) compadd "$@" \ $(_call_program list-printer-options lpoptions $printer -l | \ @@ -136,9 +152,9 @@ _lp() '-E[Force encryption]' \ '-U:username (for connection to server):_users' \ '-h:alternate server:_hosts' \ - '(-a)-P+[destination printer]:printers:_printers' \ - '(-P)-a[all printers]' \ - '-l[long listing]' \ + '(-a)-P+[Destination printer]:printers:_printers' \ + '(-P)-a[All printers]' \ + '-l[Long listing]' \ '*:poll interval (+seconds):' ;; @@ -147,7 +163,7 @@ _lp() '-E[Force encryption]' \ '-U:username (for connection to server):_users' \ '-h:alternate server:_hosts' \ - '-P+[destination printer]:printers:_printers' \ + '-P+[Destination printer]:printers:_printers' \ '*:job ids:_lp_list_jobs' ;; @@ -156,12 +172,12 @@ _lp() '-E[Force encryption]' \ '-U:username (for connection to server):_users' \ '-h:alternate server:_hosts' \ - '(-p -l -r -x)-d[set default printer]:printers:_printers' \ + '(-p -l -r -x)-d+[Set default printer]:printers:_printers' \ '(-l -x)*-o:job options:_lp_job_options' \ - '(-d -x)-p[destination printer for options]:printers:_printers' \ - '(-d -o -r -x)-l[list options]' \ + '(-d -x)-p+[Destination printer for options]:printers:_printers' \ + '(-d -o -r -x)-l[List options]' \ '(-d -l -x)*-r:remove option:_lp_job_options' \ - '(-d -l -r -o)-x[remove all options]:printers:_printers' + '(-d -l -r -o)-x+[Remove all options]:printers:_printers' ;; (lpstat) @@ -170,18 +186,18 @@ _lp() '-R[Shows print job ranking]' \ '-U:username (for connection to server):_users' \ '-W:which jobs:(completed not-completed)' \ - '-a[Show accepting state]:printers:_printers' \ + '-a+[Show accepting state]:printers:_printers' \ '-c:printer classes:' \ '-d[Show current default destination]' \ '-h:hostname (alternate server):_hosts' \ - '-l[long listing]' \ - '-o[destinations]:printers:_printers' \ - '-p:printers:_printers' \ + '-l[Long listing]' \ + '-o+[Destinations]:printers:_printers' \ + '-p+:printers:_printers' \ '-r[CUPS server running status]' \ '-s[Status summary]' \ '-t[All status info]' \ - '-u[list jobs by users]:users:_users' \ - '-v[show devices]:printers:_printers' + '-u[List jobs by users]:users:_users' \ + '-v+[Show devices]:printers:_printers' ;; (lpr) @@ -189,38 +205,73 @@ _lp() '-E[Force encryption]' \ '-H:hostname (alternate server):_hosts' \ '(-C -J -T)'-{C,J,T}':job name:' \ - '-P+[destination printer]:printers:_printers' \ + '-P+[Destination printer]:printers:_printers' \ '-U:username (for connection to server):_users' \ '-#[Copies]:copies (1--100):' \ '-h[Disables banner printing]' \ - '-l[raw file]' \ + '-l[Raw file]' \ '-m[Send an email on job completion]' \ '*-o:print job options:_lp_job_options' \ - '-p[format with shaded header incl. date, time etc.]' \ + '-p[Format with shaded header incl. date, time etc.]' \ '-q[Hold job for printing.]' \ - '-r[delete files after printing]' \ + '-r[Delete files after printing]' \ '*:PS/PDF files:_pspdf' ;; (lp) _arguments \ '-E[Force encryption]' \ - '-U[username (for connection to server)]:username:_users' \ + '-U[Username (for connection to server)]:username:_users' \ '-c[(OBSOLETE) copy to spool dir before printing]' \ - '-d[destination printer]:printers:_printers' \ + '-d+[Destination printer]:printers:_printers' \ '-h:hostname (alternate server):_hosts' \ - '-i[job id to modify]:job id:' \ + '-i[Job id to modify]:job id:' \ '-m[Send an email on job completion]' \ '-n[Copies]:copies (1--100):' \ '*-o:print job options:_lp_job_options' \ '-q[Job priority -- 1 (lowest) to 100 (highest)]:priority:' \ '-s[Dont report resulting job IDs]' \ '-t[Sets the job name]:job name:' \ - '-u[job submission username]:username:_users' \ + '-u[Job submission username]:username:_users' \ '-H[Time to print]:print time (or enter hh\:mm):(hold immediate restart resume)' \ '-P:page range list:' \ '*:PS/PDF files:_pspdf' ;; + + (lpinfo) + _arguments \ + '-E[Force encryption]' \ + '-U[Username (for connection to server)]:username:_users' \ + '-h:hostname (alternate server):_hosts' \ + '-l[Shows a "long" listing of devices or drivers]' \ + {--exclude-schemes,--include-schemes}'[Device/PPD schemes to filter from results]:scheme-list:' \ + '(-v --timeout)--device-id[IEEE-1284 device ID to match]:device-id-string:' \ + '(-v --timeout)--language:locale:' \ + '(-v --timeout)--product[Product to match]:name:' \ + '(-v --timeout)--make-and-model[Make and model to match]:name:' \ + '(-v --timeout)-m[List available drivers]' \ + '(-m --device-id --language --make-and-model --product)--timeout[Timeout when listing devices with -v]:timeout (seconds):' \ + '(-m --device-id --language --make-and-model --product)-v[List available devices]' + ;; + + (lpadmin) + _arguments \ + '-E[Force encryption/Enable destination]' \ + '-U[Username (for connection to server)]:username:_users' \ + '-h:hostname (alternate server):_hosts' \ + '(-p -R -x -o)-d+[Default printer]:printers:_printers' \ + '(-d -x)-p+[Configure printer]:printers:_printers' \ + '(-p -R -d -o)-x+[Delete printer]:printers:_printers' \ + '(-x -d)-R[Name-default]:name-default:' \ + '-c:printer classes:' \ + '-m:model:' \ + '(-x -d)*-o:options:_lp_job_options' \ + '-r[Remove from class]:class:' \ + '-u[Access policy]:access policy:' \ + '-v[Device-uri of printer queue]:device-uri:' \ + '-D[Text description of destination]:info:' \ + '-L[Location of the printer]:location:' \ + '-P[PPD file to use]:PPD file:_files "*.(#i)ppd(-.)"' esac } diff --git a/Completion/Unix/Command/_nm b/Completion/Unix/Command/_nm new file mode 100644 index 000000000..276a38f19 --- /dev/null +++ b/Completion/Unix/Command/_nm @@ -0,0 +1,29 @@ +#compdef nm + +# This is a stub. It's main reason for existence is to offer +# object files with nm. Feel free to extend it. If you do, remove +# this comment. + +local state context line expl +local -A opt_args +local -a args +integer ret=1 + +if _pick_variant gnu='Free Soft' unix --version; then + args+=(-s --) +fi +args+=('*:file:->file') + +_arguments "$args[@]" && ret=0 + +case $state in + (file) + _alternative \ + "object-files:object file:_path_files -g '*.o'" \ + "executable-files:executable file:_path_files -g '*(*)'" \ + "dynamic-libraries:dynamic library:_path_files -g '*.so'" \ + "static-libraries:static library:_path_files -g '*.a'" && ret=0 + ;; +esac + +return ret diff --git a/Completion/Unix/Command/_perforce b/Completion/Unix/Command/_perforce index 08c42cbce..2c1365a79 100644 --- a/Completion/Unix/Command/_perforce +++ b/Completion/Unix/Command/_perforce @@ -3,7 +3,7 @@ # Maintainer: Peter Stephenson <pws@csr.com>. # Increasingly loosely based on _cvs version 1.17. -# Completions currently based on Perforce release 2006.2. +# Completions currently based on Perforce release 2010.2. # Styles, tags and contexts # ========================= @@ -603,7 +603,7 @@ _perforce_global_options() { _perforce_branches() { local bline match mbegin mend local -a bl - bl=(${${${(f)"$(_perforce_call_p4 branches branches 2>/dev/null)"}##Branch }/ /:}) + bl=(${${${${(f)"$(_perforce_call_p4 branches branches 2>/dev/null)"}##Branch }//:/\\:}/ /:}) [[ $#bl -eq 1 && $bl[1] = '' ]] && bl=() (( $#bl )) && _describe -t branches 'Perforce branch' bl } @@ -685,7 +685,7 @@ awk '/^Client:/ { print $2 }')") # Limit to the 20 most recent changes by default to avoid huge # output. cl=( -${${${${(f)"$(_perforce_call_p4 changes changes $amax $xargs $cstatus \$file)"}##Change\ }//\ on\ /:}/\ by\ /\ } +${${${${${(f)"$(_perforce_call_p4 changes changes $amax $xargs $cstatus \$file)"}##Change\ }//:/\\:}//\ on\ /:}/\ by\ /\ } ) # "default" can't have shelved files in it... [[ $ctype = shelved* ]] || cl+=("default:change not yet numbered") @@ -711,7 +711,7 @@ _perforce_clients() { compset -P '//' && slash=(-S/ -q) fi - cl=(${${${(f)"$(_perforce_call_p4 clients clients)"}##Client\ }/\ /:}) + cl=(${${${${(f)"$(_perforce_call_p4 clients clients)"}##Client\ }//:/\\:}/\ /:}) [[ $#cl -eq 1 && $cl[1] = '' ]] && cl=() _describe -t clients 'Perforce client' cl $slash } @@ -722,7 +722,7 @@ _perforce_counters() { local cline match mbegin mend local -a cl - cl=(${${${(f)"$(_perforce_call_p4 counters counters)"}/\ /:}/\=/current value}) + cl=(${${${${(f)"$(_perforce_call_p4 counters counters)"}//:/\\:}/\ /:}/\=/current value}) [[ $#cl -eq 1 && $cl[1] = '' ]] && cl=() _describe -t counters 'Perforce counter' cl } @@ -796,7 +796,7 @@ _perforce_depots() { local dline match mbegin mend local -a dl - dl=(${${${(f)"$(_perforce_call_p4 depots depots)"}##Depot\ }/\ /:}) + dl=(${${${${(f)"$(_perforce_call_p4 depots depots)"}##Depot\ }//:/\\:}/\ /:}) [[ $#dl -eq 1 && $dl[1] = '' ]] && dl=() _describe -t depots 'depot name' dl } @@ -1594,7 +1594,7 @@ _perforce_submit_options() { _perforce_pids() { local -a ul - ul=(${${${(f)"$(_perforce_call_p4 monitor monitor show 2>/dev/null)"}# *}/\ /:}) + ul=(${${${${(f)"$(_perforce_call_p4 monitor monitor show 2>/dev/null)"}# *}//:/\\:}/\ /:}) [[ $#ul -eq 1 && $ul[1] = '' ]] && ul=() _describe -t id 'process ID' ul } @@ -1604,7 +1604,7 @@ _perforce_pids() { _perforce_users() { local -a ul - ul=(${${(f)"$(_perforce_call_p4 users users)"}/\ /:}) + ul=(${${${(f)"$(_perforce_call_p4 users users)"}//:/\\:}/\ /:}) [[ $#ul -eq 1 && $ul[1] = '' ]] && ul=() _describe -t users 'Perforce user' ul } @@ -1686,6 +1686,7 @@ _perforce_cmd_annotate() { '-a[all, show both added and deleted lines]' \ '-c[output change numbers instead of revisions]' \ '-i[follow branches (integration records)]' \ + '-I[follow integrations to get change numbers]' \ '-q[quiet, suppress one-line file header]' \ '*::file:_perforce_files -tR' } @@ -1748,7 +1749,8 @@ _perforce_cmd_change() { '(-d -i -f)-o[output specification to standard output]' \ '(-d -o)-i[read specification from standard input]' \ '(-d -o)-u[force change of jobs or description by owner]' \ - "(-i)1::change:_perforce_changes$ctype" + "(-i)1::change:_perforce_changes$ctype" \ + '-t[specify visibility type]:visibility type:(public restricted)' } @@ -1800,6 +1802,22 @@ _perforce_cmd_clients() { } +(( $+functions[_perforce_cmd_copy] )) || +_perforce_cmd_copy() { + local range + # If -s is present, the first normal argument can't have revRange. + [[ ${words[(I)-s]} -eq 0 ]] && range=" -tR" + _arguments -s : \ + '-b[select branch]:branch:_perforce_branches' \ + '-c[select change for copy]:change:_perforce_changes -tc' \ + '-n[no action, dummy run]' \ + '-r[reverse direction of copy with branch]' \ + '-s[select source with -b]:source file:_perforce_files -tR' \ + '-v[leave newly copied files uncopied till sync]' \ + "1:file:_perforce_files$range" \ + '*::file:_perforce_files' +} + (( $+functions[_perforce_cmd_counter] )) || _perforce_cmd_counter() { _arguments -s : \ @@ -1942,7 +1960,8 @@ _perforce_cmd_export() { '(-j)-l[specify number of lines]:number of lines: ' \ '(-j)-F[specify filter]:filter pattern: ' \ '(-c)-r[raw format]' \ - '-J[specify file prefix]:file prefix: ' + '-J[specify file prefix]:file prefix: ' \ + '-T[space-separated list of tables not to export]' } @@ -2117,8 +2136,8 @@ _perforce_cmd_help() { (( $+functions[_perforce_cmd_info] )) || _perforce_cmd_info() { - # No arguments - _arguments -s : + _arguments -s : \ + '-s[don'\''t check for unknown users or clients]' } @@ -2257,6 +2276,7 @@ _perforce_cmd_labelsync() { '-d[delete files from label]' \ '-n[no effect, dummy run]' \ '-l[specify label]:label:_perforce_labels' \ + '-q[suppress informational messages]' \ '*::file:_perforce_files -tR' } @@ -2407,6 +2427,19 @@ _perforce_cmd_passwd() { } +(( $+functions[_perforce_cmd_ping] )) || +_perforce_cmd_ping() { + _arguments -s : \ + '-c[specify count of messages]:count of messages: ' \ + '-t[specify total time of test]:time in seconds: ' \ + '-i[specify iterations for test]:number of iterations: ' \ + '-f[transmit continuously without waiting for responses]' \ + '-p[specify pause between tests]:pause in seconds: ' \ + '-s[specify send size]:send size in octets: ' \ + '-r[specify receive size]:receive size in octets: ' +} + + (( $+functions[_perforce_cmd_print] )) || _perforce_cmd_print() { _arguments -s : \ @@ -2437,6 +2470,15 @@ _perforce_cmd_protects() { } +(( $+functions[_perforce_cmd_pull] )) || +_perforce_cmd_pull() { + _arguments -s : \ + '-i[repeat as specified]:seconds between repeats: ' \ + '-u[retrieve file content rather than journal]' \ + '-p[display information about pending transfers]' \ + '-J[specify prefix for journal file]:journal file prefix: ' +} + (( $+functions[_perforce_cmd_reopen] )) || _perforce_cmd_reopen() { # Assume user doesn't want to reopen to same changelist. @@ -2462,7 +2504,9 @@ _perforce_cmd_replicate() { '-J[specify file prefix]:file prefix: ' \ '-k[keep pipe open]' \ '-o[specify output file]:output file:_files' \ + '-R[reconnect on failure, needs -i]' \ '-s[specify file to track state]:state file:_files' \ + '-T[space-separate list of tables not to transfer]' \ '-x[terminate when journal rotates]' \ '*::->_command' } @@ -2580,6 +2624,7 @@ _perforce_cmd_sync() { '-f[force resynchronisation]' \ '-n[show operations but don'\''t perform them]' \ '-k[bypass client file update]' \ + '-q[suppress informational messages]' \ '*::file:_perforce_files -tR' } diff --git a/Completion/Unix/Command/_perl b/Completion/Unix/Command/_perl index 20d9f2d83..b00baa6ed 100644 --- a/Completion/Unix/Command/_perl +++ b/Completion/Unix/Command/_perl @@ -3,17 +3,23 @@ # zsh completion code for the Perl interpreter # Adam Spiers <adam@spiers.net> # +# Completions currently based on Perl 5.14.1. _perl () { _arguments -s \ - '-0-:input record separator in octal (\0, if no argument): ' \ + '-0-[input record separator ($/)]:$/ in octal or hex (\0, if no argument)' \ '-a[autosplit mode with -n or -p (splits $_ into @F)]' \ + '-C-[control some unicode features]: :_perl_unicode_flags' \ "-c[check syntax only (runs BEGIN and END blocks)]" \ - '-d[run scripts under debugger]' \ - '-d\:-[run under control of a debugging/tracing module]:debugging/tracing module:_perl_modules --strip-prefix --perl-hierarchy=Devel' \ - '-D-:set debugging flags (argument is a bit mask or flags): ' \ - "*-e+:one line of script. Several -e's allowed. Omit [programfile]." \ - "-F-:split() pattern for autosplit (-a). The //'s are optional.: " \ + '( -dt -d: -dt:)-d[run scripts under debugger]' \ + '(-d -d: -dt:)-dt[run scripts under debugger (debugged code uses threads)]' \ + '(-d -dt -dt:)-d\:-[run under control of a debugging/tracing module]:debugging/tracing module:_perl_modules --strip-prefix --perl-hierarchy=Devel' \ + '(-d -dt -d: )-dt\:-[run under control of a debugging/tracing module (debugged coded uses threads)]:debugging/tracing module:_perl_modules --strip-prefix --perl-hierarchy=Devel' \ + '-D-[set debugging flags]: :_perl_debugging_flags' \ + '( -E)*-e+[run one line of program]:one line of program' \ + '(-e )*-E+[like -e but enable all optional features]:one line of program: ' \ + '-f[disable executing $Config{sitelib}/sitecustomize.pl at startup]' \ + '-F-[split() pattern for autosplit (-a)]:split() pattern, // is optional' \ '-h[list help summary]' \ '-i-[edit <> files in place (make backup if extension supplied)]:backup file extension: ' \ '*-I-[specify @INC/#include directory (may be used more than once)]:include path:_files -/' \ @@ -21,18 +27,21 @@ _perl () { \*{-m,-M}"-[module.. executes \`use/no module...' before executing your script]:module:_perl_m_opt" \ "-n[assume 'while (<>) { ... }' loop around your script]" \ "-p[assume loop like -n but print line also like sed]" \ - "-P[run script through C preprocessor before compilation]" \ + '-P[run script through C preprocessor before compilation (deprecated)]' \ "-s[enable some switch parsing for switches after script name]" \ "-S[look for the script using PATH environment variable]" \ - "-T[turn on tainted checks]" \ + '( -T)-t[turn on taint checks but only issue warnings]' \ + '(-t )-T[turn on taint checks]' \ "-u[dump core after parsing script]" \ "-U[allow unsafe operations]" \ "-v[print version number, patchlevel plus VERY IMPORTANT perl info]" \ "-V-[print perl configuration information]:configuration keys:_perl_config_vars" \ - '-w[turn warnings on for compilation of your script. Recommended]' \ + '( -W -X)-w[turn warnings on for compilation of your script (recommended)]' \ + "(-w -X)-W[enable all warnings (ignores 'no warnings')]" \ + "(-w -W )-X[disable all warnings (ignores 'use warnings')]" \ '-x-[strip off text before #!perl line and perhaps cd to directory]:directory to cd to:_files -/' \ '1:Perl script:_files -/ -g "*.(p[ml]|PL|t)(-.)"' \ - '*::args: _normal' + '*::args: _normal' } _perl_m_opt () { @@ -60,4 +69,46 @@ _perl_config_vars () { compadd "$expl[@]" $add_colon -S$delimiter -q -a _perl_config_vars } +_perl_unicode_flags () { + _values -s '' 'unicode bitmask or flags' \ + 'I[ 1 STDIN is assumed to be in UTF-8]' \ + 'O[ 2 STDOUT will be in UTF-8]' \ + 'E[ 4 STDERR will be in UTF-8]' \ + 'S[ 7 I + O + E]' \ + 'i[ 8 UTF-8 is the default PerlIO layer for input streams]' \ + 'o[ 16 UTF-8 is the default PerlIO layer for output streams]' \ + 'D[ 24 i + o]' \ + 'A[ 32 the @ARGV elements are expected to be strings encoded in UTF-8]' \ + 'L[ 64 make "IOEioA" conditional on the locale environment variables]' \ + 'a[256 set ${^UTF8CACHE} to -1, used for debugging]' \ +} + +_perl_debugging_flags () { + _values -s '' 'debugging bitmask or flags' \ + 'p[ 1 Tokenizing and parsing (with v, displays parse stack)]' \ + 's[ 2 Stack snapshots (with v, displays all stacks)]' \ + 'l[ 4 Context (loop) stack processing]' \ + 't[ 8 Trace execution]' \ + 'o[ 16 Method and overloading resolution]' \ + 'c[ 32 String/numeric conversions]' \ + 'P[ 64 Print profiling info, preprocessor command for -P, source file input state]' \ + 'm[ 128 Memory and SV allocation]' \ + 'f[ 256 Format processing]' \ + 'r[ 512 Regular expression parsing and execution]' \ + 'x[ 1024 Syntax tree dump]' \ + 'u[ 2048 Tainting checks]' \ + 'U[ 4096 Unofficial, User hacking (reserved for private, unreleased use)]' \ + 'H[ 8192 Hash dump -- usurps values()]' \ + 'X[ 16384 Scratchpad allocation]' \ + 'D[ 32768 Cleaning up]' \ + 'S[ 66536 Thread synchronization]' \ + 'T[ 131072 Tokenising]' \ + 'R[ 262144 Include reference counts of dumped variables (eg when using -Ds)]' \ + 'J[ 524288 Do not s,t,P-debug (Jump over) opcodes within package DB]' \ + 'v[1048576 Verbose: use in conjunction with other flags]' \ + 'C[2097152 Copy On Write]' \ + 'A[4194304 Consistency checks on internal structures]' \ + 'q[8388608 quiet - currently only suppresses the "EXECUTING" message]' \ +} + _perl "$@" diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep index f65324a81..e460202a1 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -1,112 +1,89 @@ #compdef pgrep pkill -local context state line +local context state line ret=1 expl typeset -A opt_args typeset -a arguments arguments=('-P[parent process id]:parent process id:->ppid' - '-g[match only in process group ids]:group:->pgid' - '-G[match only real group id]:group:->group' - '-s[match only session id]:session id:->sid' - '-t[match only controlled by terminal]:terminal device:->tty' - '-u[match only effective user id]:user:->user' - '-U[match only real user id]:user:->user' + '-g[match only in process group ids]:group:->pgid' + '-G[match only real group id]:group:_groups' + '-s[match only session id]:session id:->sid' + '-t[match only controlled by terminal]:terminal device:->tty' + '-u[match only effective user id]:user:_users' + '-U[match only real user id]:user:_users' '(-n)-o[oldest process]' - '(-o)-n[newest process]' - '-f[match against full command line]' - '-v[negate matching]' - '-x[match exactly]' - '*:process name:->pname') + '(-o)-n[newest process]' + '-f[match against full command line]' + '-v[negate matching]' + '-x[match exactly]' + '*:process name:->pname') if [[ $service == 'pkill' ]] then - arguments+=('-'${^signals}'[signal]') + arguments+=('-'${^signals}'[signal]') elif [[ $service == 'pgrep' ]] then - arguments+=('-d[output delimiter]:delimiter:compadd ${(s\:\:)IFS}' - '-l[list name in addition to id]') + arguments+=('-d[output delimiter]:delimiter:compadd ${(s\:\:)IFS}' + '-l[list name in addition to id]') fi -_arguments -s -w $arguments +_arguments -s -w $arguments && ret=0 case $state in - (tty) - compset -P '*,' - - local -a used - used=(${(s:,:)IPREFIX}) - - compadd -S ',' -q -F used /dev/tty*(:t) - ;; - - (sid) - compset -P '*,' - - local -a used sid - used=(${(s:,:)IPREFIX}) - sid=(${(uon)$(ps -A o sid=)}) - - compadd -S ',' -q -F used $sid - ;; - - (ppid) - compset -P '*,' - - local -a used ppid - used=(${(s:,:)IPREFIX}) - ppid=(${(uon)$(ps -A o ppid=)}) - - compadd -S ',' -q -F used $ppid - ;; - - (pgid) - compset -P '*,' - - local -a used pgid - used=(${(s:,:)IPREFIX}) - pgid=(${(uon)$(ps -A o pgid=)}) - - compadd -S ',' -q -F used $pgid - ;; - - (pname) - if (( ${+opt_args[-x]} )) && (( ${+opt_args[-f]} )) - then - compadd ${(u)${(f)"$(ps -A o cmd=)"}} - else - compadd ${(u)${(f)"$(ps -A co cmd=)"}} - fi - ;; - - (group) - compset -P '*,' - - local group - group=$(getent group) - - local -a groups ids - groups=(${${(f)group}%%:*}) - ids=(${${${(f)group}#*:*:}%%:*}) - - local -a used - used=(${(s:,:)IPREFIX}) - - compadd -S ',' -q -F used -d ids $groups $groups - ;; - - (user) - compset -P '*,' - - local passwd - passwd=$(getent passwd) - - local -a users ids - users=(${${(f)passwd}%%:*}) - ids=(${${${(f)passwd}#*:*:}%%:*}) - - local -a used - used=(${(s:,:)IPREFIX}) - - compadd -S ',' -q -F used -d ids $users $users - ;; -esac + (tty) + compset -P '*,' + + local -a used ttys + used=(${(s:,:)IPREFIX}) + + ttys=( /dev/tty*(N) /dev/pts/*(N) ) + _wanted tty expl 'terminal device' compadd -S ',' -q -F used ${ttys#/dev/} + ;; + + (sid) + compset -P '*,' + + local -a used sid + used=(${(s:,:)IPREFIX}) + sid=(${(uon)$(ps -A o sid=)}) + + _wanted sid expl 'session id' compadd -S ',' -q -F used $sid + ;; + + (ppid) + compset -P '*,' + + local -a used ppid + used=(${(s:,:)IPREFIX}) + ppid=(${(uon)$(ps -A o ppid=)}) + + _wanted ppid expl 'parent process id' compadd -S ',' -q -F used $ppid + ;; + + (pgid) + compset -P '*,' + + local -a used pgid + used=(${(s:,:)IPREFIX}) + pgid=(${(uon)$(ps -A o pgid=)}) + + _wanted pgid expl 'process group id' compadd -S ',' -q -F used $pgid + ;; + + (pname) + local ispat="pattern matching " + if (( ${+opt_args[-x]} )) + then + ispat="" + fi + if (( ${+opt_args[-f]} )) + then + _wanted pname expl $ispat'process command line' compadd ${(u)${(f)"$(ps -A o cmd=)"}} + else + _wanted pname expl $ispat'process name' compadd ${(u)${(f)"$(ps -A co cmd=)"}} + fi + ;; + +esac && ret=0 + +return ret diff --git a/Completion/Unix/Command/_quilt b/Completion/Unix/Command/_quilt index a2fd799a6..130f38149 100644 --- a/Completion/Unix/Command/_quilt +++ b/Completion/Unix/Command/_quilt @@ -1,30 +1,241 @@ #compdef quilt +local -a tmp +local rc + +_quilt_applied () { + tmp=( ${(f)"$(quilt applied 2>&1)"} ) + rc=$? + if (( rc == 0 )); then + _wanted -V 'applied patches' expl 'patch' compadd "${tmp[@]}" + else + _message "No applied patches" + fi +} + +_quilt_series () { + _wanted -V 'patches' expl 'patch' compadd ${(f)"$(quilt series)"} +} + +_quilt_unapplied () { + tmp=( ${(f)"$(quilt unapplied 2>&1)"} ) + rc=$? + if (( rc == 0 )); then + _wanted -V 'unapplied patches' expl 'patch' compadd "${tmp[@]}" + else + _message "No unapplied patches" + fi +} + _arguments \ - '--trace' \ - '--quiltrc:config file:_files' \ - '--version' \ - ':quilt command:(add files import previous setup annotate fold mail push - snapshot applied fork new refresh top delete graph next remove unapplied - diff grep patches rename upgrade edit header pop series)' \ + '--trace[Runs the command in bash trace mode]' \ + '--quiltrc[Use the specified configuration file]:files:_files' \ + '--version[Print the version number and exit]' \ + ':quilt command:(add annotate applied delete diff edit files fold fork graph + grep header import mail new next patches pop previous push refresh rename + revert series setup shell snapshot top unapplied upgrade)' \ '*::subcmd:->subcmd' && return 0 -case "$state" in - (subcmd) - +case "$state" in (subcmd) case "$words[1]" in - (applied|delete|files|graph|header|next|previous|refresh|unapplied) - _wanted -V 'patches' expl 'patch' compadd ${(f)"$(quilt series)"} - ;; - (push) - _wanted -V 'unapplied patches' expl 'patch' compadd ${(f)"$(quilt unapplied)"} - ;; + (add) + _arguments '-h' \ + '-P[Patch to add files to]:quilt series:_quilt_series' \ + '*:files:_files' + ;; + (annotate) + _arguments '-h' \ + '-P[Stop checking for changes at the specified rather than the topmost patch]:quilt series:_quilt_series' \ + ':files:_files' + ;; + (applied) + _arguments '-h' \ + ':quilt series:_quilt_series' + ;; + (delete) + _arguments '-h' \ + '-n[Delete the next patch after topmost]' \ + '-r[Remove the deleted patch file from the patches directory as well]' \ + '--backup[Rename the patch file to patch~ rather than deleting it]' \ + ':quilt series:_quilt_series' + ;; + (diff) + _arguments '-h' \ + '-p[Select a patch style]:quilt patch style:(0 1 ab)' \ + '-u[Create a unified diff]' \ + '-U[Create a unified diff with num lines of context]:quilt unified diff: ' \ + '-c[Create a context diff]' \ + '-C[Create a context diff with num lines of context]:quilt context diff: ' \ + '--no-timestamps[Do not include file timestamps in patch headers]' \ + '--no-index[Do not output Index: lines]' \ + '-z[Write to standard output the changes that have been made relative to the topmost or specified patch]' \ + '-R[Create a reverse diff]' \ + '-P[Create a diff for the specified patch]:quilt series:_quilt_series' \ + '--combine[Create a combined diff for all patches between this patch and the patch specified with -P]:quilt series:_quilt_series' \ + '--snapshot[Diff against snapshot]' \ + '--diff=[Use the specified utility for generating the diff]:quilt select diff utility:_command_names -e' \ + '--color=[Use syntax coloring]:quilt select color:(always auto never)' \ + '--sort[Sort files by their name]' \ + '*:files:_files' + ;; + (edit) + _arguments '-h' \ + '*:files:_files' + ;; + (files) + _arguments '-h' \ + '-a[List all files in all applied patches]' \ + '-l[Add patch name to output]' \ + '-v[Verbose, more user friendly output]' \ + '--combine[Create a listing for all patches between this patch and the topmost or specified patch]:quilt series:_quilt_series' \ + ':quilt series:_quilt_series' + ;; + (fold) + _arguments '-h' \ + '-R[Apply patch in reverse]' \ + '-q[Quiet operation]' \ + '-f[Force apply]' \ + '-p[The number of pathname components to strip]:quilt select strip-level: ' + ;; + (fork) + _arguments '-h' + ;; + (graph) + _arguments '-h' \ + '--all[Generate a graph including all applied patches and their dependencies]' \ + '--reduce[Eliminate transitive edges from the graph]' \ + '--lines[Compute dependencies by looking at the lines the patches modify]:quilt select lines: ' \ + '--edge-labels=files[Label graph edges with the file names that the adjacent patches modify]' \ + '-T ps[Directly produce a PostScript output file]' \ + ':quilt series:_quilt_series' + ;; + (header) + _arguments '-h' \ + '-a[Append the exiting patch header]' \ + '-r[Replace the exiting patch header]' \ + '-e[Edit the header in $EDITOR]' \ + '--strip-diffstat[Strip diffstat output from the header]' \ + '--strip-trailing-whitespace[Strip trailing whitespace at the end of lines of the header]' \ + '--backup[Create a backup copy of the old version of a patch as patch~]' \ + ':quilt series:_quilt_series' + ;; + (import) + _arguments '-h' \ + '-p[Number of directory levels to strip when applying]:quilt select strip-level: ' \ + '-R[Apply patch in reverse]' \ + '-P[Patch filename to use inside quilt]:quilt select patch filename: ' \ + '-f[Overwrite/update existing patches]' \ + '-d[When overwriting in existing patch, keep the old (o), all (a), or new (n) patch header]:quilt select patch:(a n o)' \ + '*:files:_files' + ;; + (mail) + _arguments '-h' \ + '-m[Text to use as the text in the introduction]:quilt select text: ' \ + '--prefix[Use an alternate prefix in the bracketed part of the subjects generated]:quilt select prefix: ' \ + '--mbox[Store all messages in the specified file in mbox format]:files:_files' \ + '--send[Send the messages directly]' \ + '--sender[The envelope sender address to use]:quilt select sender: ' \ + '--from[From header]:quilt select from: ' \ + '--subject[Subject header]:quilt select subject: ' \ + '--to[Append a recipient to the To header]:quilt select to: ' \ + '--cc[Append a recipient to the Cc header]:quilt select cc: ' \ + '--bcc[Append a recipient to the Bcc header]:quilt select bcc: ' \ + '--signature[Append the specified signature to messages]:files:_files' \ + '--reply-to[Add the appropriate headers to reply to the specified message]:quilt select reply-to: ' \ + '*:quilt series:_quilt_series' + ;; + (new) + _arguments '-h' + ;; + (next) + _arguments '-h' \ + ':quilt series:_quilt_series' + ;; + (patches) + _arguments '-h' \ + '-v[Verbose, more user friendly output]' \ + ':files:_files' + ;; (pop) - _wanted -V 'applied patches' expl 'patch' compadd ${(f)"$(quilt applied)"} - ;; + _arguments '-h' \ + '-a[Remove all applied patches]' \ + '-f[Force remove]' \ + '-R[Always verify if the patch removes cleanly]' \ + '-q[Quiet operation]' \ + '-v[Verbose operation]' \ + ':quilt applied:_quilt_applied' + ;; + (previous) + _arguments '-h' \ + ':quilt series:_quilt_series' + ;; + (push) + _arguments '-h' \ + '-a[Apply all patches in the series file]' \ + '-q[Quiet operation]' \ + '-f[Force apply, even if the patch has rejects]' \ + '-v[Verbose operation]' \ + '--leave-rejects[Leave around the reject files patch produced]' \ + '--color=[Use syntax coloring]:quilt select color:(always auto never)' \ + ':quilt unapplied:_quilt_unapplied' + ;; + (refresh) + _arguments '-h' \ + '-p[Select a patch style]:quilt patch style:(0 1 ab)' \ + '-u[Create a unified diff]' \ + '-U[Create a unified diff with num lines of context]:quilt unified diff: ' \ + '-c[Create a context diff]' \ + '-C[Create a context diff with num lines of context]:quilt context diff: ' \ + '-z[Create a new patch containing the changes instead of refreshing the topmost patch]:quilt select new patch name: ' \ + '--no-timestamps[Do not include file timestamps in patch headers]' \ + '--no-index[Do not output Index: lines]' \ + '--diffstat[Add a diffstat section to the patch header, or replace the existing diffstat section]' \ + '-f[Enforce refreshing of a patch that is not on top]' \ + '--backup[Create a backup copy of the old version of a patch as patch~]' \ + '--sort[Sort files by their name instead of preserving the original order]' \ + '--strip-trailing-whitespace[Strip trailing whitespace at the end of lines]' \ + ':quilt series:_quilt_series' + ;; + (rename) + _arguments '-h' \ + '-P[Patch to rename]:quilt series:_quilt_series' + ;; + (revert) + _arguments '-h' \ + '-P[Revert changes in the named patch]:quilt series:_quilt_series' \ + '*:files:_files' + ;; + (series) + _arguments '-h' \ + '-v[Verbose, more user friendly output]' + ;; + (setup) + _arguments '-h' \ + '-d[Optional path prefix for the resulting source tree]:quilt select path-prefix: ' \ + '--sourcedir[Directory that contains the package sources]:quilt select package sources directory: ' \ + '-v[Verbose debug output]' \ + ':files:_files' + ;; + (shell) + _arguments '-h' \ + ':quilt select shell command:_command_names -e' + ;; + (snapshot) + _arguments '-h' \ + '-d[Remove current snapshot]' + ;; + (top) + _arguments '-h' + ;; + (unapplied) + _arguments '-h' \ + ':quilt series:_quilt_series' + ;; + (upgrade) + _arguments '-h' + ;; (*) - _files - ;; + ;; esac ;; esac diff --git a/Completion/Unix/Command/_rsync b/Completion/Unix/Command/_rsync index cdb40ab46..b999c1bbd 100644 --- a/Completion/Unix/Command/_rsync +++ b/Completion/Unix/Command/_rsync @@ -96,144 +96,148 @@ _rsync_files() { _alternative "files:file:_files" "remote-files:remote file:_rsync_remote_files" } -_arguments -s \ - '*'{-v,--verbose}'[increase verbosity]' \ - {--no-v,--no-verbose}'[turn off --verbose]' \ - '--bwlimit=[limit I/O bandwidth]:KBytes per second' \ - '--port=[specify alternate port number]:port:(873)' \ - '--address=[bind to the specified address]:bind address:_bind_addresses' \ - '(-T --temp-dir)'{-T,--temp-dir=}'[create temporary files in specified directory]:directory:_directories' \ - '--sockopts=[specify custom TCP options]' \ - '(-4 -6 --ipv4 --ipv6)'{-4,--ipv4}'[prefer IPv4]' \ - '(-4 -6 --ipv4 --ipv6)'{-6,--ipv6}'[prefer IPv6]' \ - - daemon \ - '(-)'{-h,--help}'[display help information]' \ - '--config=[specify alternate rsyncd.conf file]:file:_files' \ - '--daemon[run as an rsync daemon]' \ - '--detach[detach from the parent]' \ - '--no-detach[do not detach from the parent]' \ - - client \ - '(-)--help[display help information]' \ - '*: :_rsync_files' \ - '(-q --quiet)'{-q,--quiet}'[suppress non-error messages]' \ - '--no-motd[suppress the daemon message-of-the-day output]' \ - '(-c --checksum)'{-c,--checksum}'[skip based on checksums, not mod-time & size]' \ - '(-a --archive)'{-a,--archive}'[archive mode; same as -rlptgoD (no -H)]' \ - '(-r --recursive)'{-r,--recursive}'[recurse into directories]' \ - {--no-r,--no-recursive}'[turn off --recursive]' \ - {--no-inc-recursive,--no-i-r}'[disable incremental recursive mode]' \ - '(-R --relative)'{-R,--relative}'[use relative path names]' \ - {--no-R,--no-relative}'[turn off --relative]' \ - {--no-implied-dirs,--no-i-d}'[do not send implied dirs with --relative]' \ - '(-b --backup)'{-b,--backup}'[make backups into hierarchy at indicated directory]' \ - '--backup-dir=[make backups into specified directory]:backup directory:_directories' \ - '--suffix=[set backup suffix]:suffix:(\~)' \ - '(-u --update)'{-u,--update}'[skip files that are newer on the receiving side]' \ - '--inplace[update destination files in-place]' \ - '(--append-verify)--append[append data onto shorter files]' \ - '(--append)--append-verify[append data onto shorter files, verifying old data]' \ - '(-A --acls)'{-A,--acls}'[preserve access-control lists]' \ - '(-X --xattrs)'{-X,--xattrs}'[preserve extended attributes]' \ - '--fake-super[use xattrs to save all file attributes]' \ - '(-d --dirs)'{-d,--dirs}'[transfer directories without recursing]' \ - {--no-d,--no-dirs}'[turn off --dirs]' \ - '(-l --links)'{-l,--links}'[copy symlinks as symlinks]' \ - {--no-l,--no-links}'[turn off --links]' \ - '(-L --copy-links)'{-L,--copy-links}'[transform symlinks into referent file/dir]' \ - '(-k --copy-dirlinks)'{-k,--copy-dirlinks}'[transform a symlink to a dir into referent dir]' \ - '--copy-unsafe-links[only "unsafe" symlinks are transformed]' \ - '--safe-links[ignore symlinks that point outside the source tree]' \ - '(-H --hard-links)'{-H,--hard-links}'[preserve hard links]' \ - {--no-H,--no-hard-links}'[turn off --hard-links]' \ - '(-K --keep-dirlinks)'{-K,--keep-dirlinks}'[treat symlinked dir on receiver as dir]' \ - '(-p --perms -E --executability)'{-p,--perms}'[preserve permissions]' \ - {--no-p,--no-perms}'[turn off --perms]' \ - '(-E --executability)'{-E,--executability}'[preserve executability]' \ - '(-o --owner)'{-o,--owner}'[preserve owner]' \ - {--no-o,--no-owner}'[turn off --owner]' \ - '(-g --group)'{-g,--group}'[preserve group]' \ - {--no-g,--no-group}'[turn off --group]' \ - '(--devices --specials)-D[same as --devices --specials]' \ - '(-D)--devices[preserve devices]' \ - '--no-devices[turn off --devices]' \ - '(-D)--specials[preserve special files]' \ - '--no-specials[turn off --specials]' \ - '--no-D[turn off --devices and --specials]' \ - '(-t --times)'{-t,--times}'[preserve times]' \ - {--no-t,--no-times}'[turn off --times]' \ - '(-O --omit-dir-times)'{-O,--omit-dir-times}'[omit directories when preserving times]' \ - '--chmod[change destination permissions]:mods' \ - '(-S --sparse)'{-S,--sparse}'[handle sparse files efficiently]' \ - '(-n --dry-run)'{-n,--dry-run}'[show what would have been transferred]' \ - '(-W --whole-file)'{-W,--whole-file}'[copy files whole (without delta-transfer algorithm)]' \ - {--no-W,--no-whole-file}'[turn off --whole-file]' \ - '(-x --one-file-system)'{-x,--one-file-system}'[do not cross filesystem boundaries]' \ - '(-B --block-size)'{-B,--block-size=}'[force a fixed checksum block-size]:block size' \ - '(-e --rsh)'{-e,--rsh=}'[specify the remote shell to use]:remote-shell command:(rsh ssh)' \ - '--rsync-path=[specify path to rsync on the remote machine]:remote command' \ - '--ignore-existing[ignore files that already exist on receiving side]' \ - '(--existing --ignore-non-existing)'{--existing,--ignore-non-existing}'[ignore files that do not exist on receiving side]' \ - '--remove-source-files[synchronized files are removed from sending side]' \ - '(--delete-before --delete-during --delete-after --delete-delay)--del[an alias for --delete-during]' \ - '--delete[delete files that do not exist on the sending side]' \ - '(--del --delete-during --delete-after --delete-delay)--delete-before[receiver deletes before transfer]' \ - '(--del --delete-before --delete-after --delete-delay)--delete-during[receiver deletes during transfer]' \ - '(--del --delete-before --delete-during --delete-delay)--delete-after[receiver deletes after transfer]' \ - '(--del --delete-before --delete-during --delete-after)--delete-delay[receiver deletes after transfer]' \ - '--delete-excluded[also delete excluded files on the receiving side]' \ - '--ignore-errors[delete even if there are I/O errors]' \ - '--force[force deletion of directories even if not empty]' \ - '--max-delete=[do not delete more than NUM files]:number' \ - '--max-size=[do not transfer any file larger than specified size]:number' \ - '--min-size=[do not transfer any file smaller than specified size]:number' \ - '(-P)--partial[keep partially transferred files]' \ - '--no-partial[turn off --partial]' \ - '--partial-dir=[put a partially transferred file into specified directory]:directory:_directories' \ - '--super[receiver attempts super-user activities]' \ - '--no-super[receiver performs normal-user activities]' \ - '--delay-updates[put all updated files into place at end of transfer]' \ - '(-m --prune-empty-dirs)'{-m,--prune-empty-dirs}'[prune empty directory chains from file-list]' \ - '--numeric-ids[do not map uid/gid values by user/group name]' \ - '--timeout=[set I/O timeout in seconds for lulls in a transfer]:seconds' \ - '--contimeout=[set connect timeout in seconds for daemon connections]:seconds' \ - '(-I --ignore-times)'{-I,--ignore-times}'[do not skip files that match in size and mod-time]' \ - '--size-only[skip files that match in size]' \ - '--modify-window=[compare mod-times with reduced accuracy]:seconds' \ - '(-y --fuzzy)'{-y,--fuzzy}'[find similar file for basis if no destination file]' \ - '(--copy-dest --link-dest)*--compare-dest=[also compare destination files relative to specified directory]:directory:_directories' \ - '(--compare-dest --link-dest)*--copy-dest=[like --compare-dest, but also includes copies of unchanged files]:directory:_directories' \ - '(--compare-dest --copy-dest)*--link-dest=[hardlink to files in specified directory hierarchy when unchanged]:directory:_directories' \ - '(-z --compress)'{-z,--compress}'[compress file data during the transfer]' \ - '--compress-level=[explicitly set compression level]:number' \ - '--skip-compress=[skip compressing files with a listed suffix]:suffixes' \ - '(-C --cvs-exclude)'{-C,--cvs-exclude}'[auto-ignore files the same way CVS does]' \ - '*'{-f=,--filter=}'[add a file-filtering rule]:rule' \ - '*-F[same as --filter="dir-merge /.rsync-filter", repeated: --filter="- .rsync-filter"]' \ - '--exclude-from=[read exclude patterns from specified file]:file:_files' \ - '*--exclude=[exclude files matching pattern]:pattern' \ - '--include-from=[read include patterns from specified file]:file:_files' \ - '*--include=[do not exclude files matching pattern]:pattern' \ - '--files-from=[read list of source-file names from specified file]:file:_files' \ - '(-0 --from0)'{-0,--from0}'[all *-from file lists are delimited by nulls]' \ - '(-s --protect-args)'{-s,--protect-args}'[no space-splitting; only wildcard special-chars]' \ - '--version[print version number]' \ - '*'{-h,--human-readable}'[output numbers in a human-readable format]' \ - '--blocking-io[use blocking I/O for the remote shell]' \ - '--no-blocking-io[turn off --blocking-io]' \ - '--stats[give some file-transfer stats]' \ - '(-8 --8-bit-output)'{-8,--8-bit-output}'[leave high-bit chars unescaped in output]' \ - '(-P)--progress[show progress during transfer]' \ - '--no-progress[turn off --progress]' \ - '(--partial --progress)-P[same as --partial --progress]' \ - '(-i --itemize-changes)'{-i,--itemize-changes}'[output a change-summary for all updates]' \ - '--log-format=[deprecated version of --out-format]' \ - '--out-format=[output updates using specified format]:format' \ - '--log-file-format=[log updates using specified format]:format' \ - '--log-file=[log what rsync is doing to the specified file]:file:_files' \ - '--password-file=[read daemon-access password from file]:file:_files' \ - '--list-only[list the files instead of copying them]' \ - '(--only-write-batch)--write-batch=[write a batched update to the specified file]:file:_files' \ - '(--write-batch)--only-write-batch=[like --write-batch but w/o updating destination]:file:_files' \ - '--protocol=[force an older protocol version to be used]:number' \ - '--iconv=[request charset conversion of filenames]:number' \ - '--read-batch=[read a batched update from the specified file]:file:_files' +_rsync() { + _arguments -s \ + '*'{-v,--verbose}'[increase verbosity]' \ + {--no-v,--no-verbose}'[turn off --verbose]' \ + '--bwlimit=[limit I/O bandwidth]:KBytes per second' \ + '--port=[specify alternate port number]:port:(873)' \ + '--address=[bind to the specified address]:bind address:_bind_addresses' \ + '(-T --temp-dir)'{-T,--temp-dir=}'[create temporary files in specified directory]:directory:_directories' \ + '--sockopts=[specify custom TCP options]' \ + '(-4 -6 --ipv4 --ipv6)'{-4,--ipv4}'[prefer IPv4]' \ + '(-4 -6 --ipv4 --ipv6)'{-6,--ipv6}'[prefer IPv6]' \ + - daemon \ + '(-)'{-h,--help}'[display help information]' \ + '--config=[specify alternate rsyncd.conf file]:file:_files' \ + '--daemon[run as an rsync daemon]' \ + '--detach[detach from the parent]' \ + '--no-detach[do not detach from the parent]' \ + - client \ + '(-)--help[display help information]' \ + '*: :_rsync_files' \ + '(-q --quiet)'{-q,--quiet}'[suppress non-error messages]' \ + '--no-motd[suppress the daemon message-of-the-day output]' \ + '(-c --checksum)'{-c,--checksum}'[skip based on checksums, not mod-time & size]' \ + '(-a --archive)'{-a,--archive}'[archive mode; same as -rlptgoD (no -H)]' \ + '(-r --recursive)'{-r,--recursive}'[recurse into directories]' \ + {--no-r,--no-recursive}'[turn off --recursive]' \ + {--no-inc-recursive,--no-i-r}'[disable incremental recursive mode]' \ + '(-R --relative)'{-R,--relative}'[use relative path names]' \ + {--no-R,--no-relative}'[turn off --relative]' \ + {--no-implied-dirs,--no-i-d}'[do not send implied dirs with --relative]' \ + '(-b --backup)'{-b,--backup}'[make backups into hierarchy at indicated directory]' \ + '--backup-dir=[make backups into specified directory]:backup directory:_directories' \ + '--suffix=[set backup suffix]:suffix:(\~)' \ + '(-u --update)'{-u,--update}'[skip files that are newer on the receiving side]' \ + '--inplace[update destination files in-place]' \ + '(--append-verify)--append[append data onto shorter files]' \ + '(--append)--append-verify[append data onto shorter files, verifying old data]' \ + '(-A --acls)'{-A,--acls}'[preserve access-control lists]' \ + '(-X --xattrs)'{-X,--xattrs}'[preserve extended attributes]' \ + '--fake-super[use xattrs to save all file attributes]' \ + '(-d --dirs)'{-d,--dirs}'[transfer directories without recursing]' \ + {--no-d,--no-dirs}'[turn off --dirs]' \ + '(-l --links)'{-l,--links}'[copy symlinks as symlinks]' \ + {--no-l,--no-links}'[turn off --links]' \ + '(-L --copy-links)'{-L,--copy-links}'[transform symlinks into referent file/dir]' \ + '(-k --copy-dirlinks)'{-k,--copy-dirlinks}'[transform a symlink to a dir into referent dir]' \ + '--copy-unsafe-links[only "unsafe" symlinks are transformed]' \ + '--safe-links[ignore symlinks that point outside the source tree]' \ + '(-H --hard-links)'{-H,--hard-links}'[preserve hard links]' \ + {--no-H,--no-hard-links}'[turn off --hard-links]' \ + '(-K --keep-dirlinks)'{-K,--keep-dirlinks}'[treat symlinked dir on receiver as dir]' \ + '(-p --perms -E --executability)'{-p,--perms}'[preserve permissions]' \ + {--no-p,--no-perms}'[turn off --perms]' \ + '(-E --executability)'{-E,--executability}'[preserve executability]' \ + '(-o --owner)'{-o,--owner}'[preserve owner]' \ + {--no-o,--no-owner}'[turn off --owner]' \ + '(-g --group)'{-g,--group}'[preserve group]' \ + {--no-g,--no-group}'[turn off --group]' \ + '(--devices --specials)-D[same as --devices --specials]' \ + '(-D)--devices[preserve devices]' \ + '--no-devices[turn off --devices]' \ + '(-D)--specials[preserve special files]' \ + '--no-specials[turn off --specials]' \ + '--no-D[turn off --devices and --specials]' \ + '(-t --times)'{-t,--times}'[preserve times]' \ + {--no-t,--no-times}'[turn off --times]' \ + '(-O --omit-dir-times)'{-O,--omit-dir-times}'[omit directories when preserving times]' \ + '--chmod[change destination permissions]:mods' \ + '(-S --sparse)'{-S,--sparse}'[handle sparse files efficiently]' \ + '(-n --dry-run)'{-n,--dry-run}'[show what would have been transferred]' \ + '(-W --whole-file)'{-W,--whole-file}'[copy files whole (without delta-transfer algorithm)]' \ + {--no-W,--no-whole-file}'[turn off --whole-file]' \ + '(-x --one-file-system)'{-x,--one-file-system}'[do not cross filesystem boundaries]' \ + '(-B --block-size)'{-B,--block-size=}'[force a fixed checksum block-size]:block size' \ + '(-e --rsh)'{-e+,--rsh=}'[specify the remote shell to use]:remote-shell command:(rsh ssh)' \ + '--rsync-path=[specify path to rsync on the remote machine]:remote command' \ + '--ignore-existing[ignore files that already exist on receiving side]' \ + '(--existing --ignore-non-existing)'{--existing,--ignore-non-existing}'[ignore files that do not exist on receiving side]' \ + '--remove-source-files[synchronized files are removed from sending side]' \ + '(--delete-before --delete-during --delete-after --delete-delay)--del[an alias for --delete-during]' \ + '--delete[delete files that do not exist on the sending side]' \ + '(--del --delete-during --delete-after --delete-delay)--delete-before[receiver deletes before transfer]' \ + '(--del --delete-before --delete-after --delete-delay)--delete-during[receiver deletes during transfer]' \ + '(--del --delete-before --delete-during --delete-delay)--delete-after[receiver deletes after transfer]' \ + '(--del --delete-before --delete-during --delete-after)--delete-delay[receiver deletes after transfer]' \ + '--delete-excluded[also delete excluded files on the receiving side]' \ + '--ignore-errors[delete even if there are I/O errors]' \ + '--force[force deletion of directories even if not empty]' \ + '--max-delete=[do not delete more than NUM files]:number' \ + '--max-size=[do not transfer any file larger than specified size]:number' \ + '--min-size=[do not transfer any file smaller than specified size]:number' \ + '(-P)--partial[keep partially transferred files]' \ + '--no-partial[turn off --partial]' \ + '--partial-dir=[put a partially transferred file into specified directory]:directory:_directories' \ + '--super[receiver attempts super-user activities]' \ + '--no-super[receiver performs normal-user activities]' \ + '--delay-updates[put all updated files into place at end of transfer]' \ + '(-m --prune-empty-dirs)'{-m,--prune-empty-dirs}'[prune empty directory chains from file-list]' \ + '--numeric-ids[do not map uid/gid values by user/group name]' \ + '--timeout=[set I/O timeout in seconds for lulls in a transfer]:seconds' \ + '--contimeout=[set connect timeout in seconds for daemon connections]:seconds' \ + '(-I --ignore-times)'{-I,--ignore-times}'[do not skip files that match in size and mod-time]' \ + '--size-only[skip files that match in size]' \ + '--modify-window=[compare mod-times with reduced accuracy]:seconds' \ + '(-y --fuzzy)'{-y,--fuzzy}'[find similar file for basis if no destination file]' \ + '(--copy-dest --link-dest)*--compare-dest=[also compare destination files relative to specified directory]:directory:_directories' \ + '(--compare-dest --link-dest)*--copy-dest=[like --compare-dest, but also includes copies of unchanged files]:directory:_directories' \ + '(--compare-dest --copy-dest)*--link-dest=[hardlink to files in specified directory hierarchy when unchanged]:directory:_directories' \ + '(-z --compress)'{-z,--compress}'[compress file data during the transfer]' \ + '--compress-level=[explicitly set compression level]:number' \ + '--skip-compress=[skip compressing files with a listed suffix]:suffixes' \ + '(-C --cvs-exclude)'{-C,--cvs-exclude}'[auto-ignore files the same way CVS does]' \ + '*'{-f=,--filter=}'[add a file-filtering rule]:rule' \ + '*-F[same as --filter="dir-merge /.rsync-filter", repeated: --filter="- .rsync-filter"]' \ + '--exclude-from=[read exclude patterns from specified file]:file:_files' \ + '*--exclude=[exclude files matching pattern]:pattern' \ + '--include-from=[read include patterns from specified file]:file:_files' \ + '*--include=[do not exclude files matching pattern]:pattern' \ + '--files-from=[read list of source-file names from specified file]:file:_files' \ + '(-0 --from0)'{-0,--from0}'[all *-from file lists are delimited by nulls]' \ + '(-s --protect-args)'{-s,--protect-args}'[no space-splitting; only wildcard special-chars]' \ + '--version[print version number]' \ + '*'{-h,--human-readable}'[output numbers in a human-readable format]' \ + '--blocking-io[use blocking I/O for the remote shell]' \ + '--no-blocking-io[turn off --blocking-io]' \ + '--stats[give some file-transfer stats]' \ + '(-8 --8-bit-output)'{-8,--8-bit-output}'[leave high-bit chars unescaped in output]' \ + '(-P)--progress[show progress during transfer]' \ + '--no-progress[turn off --progress]' \ + '(--partial --progress)-P[same as --partial --progress]' \ + '(-i --itemize-changes)'{-i,--itemize-changes}'[output a change-summary for all updates]' \ + '--log-format=[deprecated version of --out-format]' \ + '--out-format=[output updates using specified format]:format' \ + '--log-file-format=[log updates using specified format]:format' \ + '--log-file=[log what rsync is doing to the specified file]:file:_files' \ + '--password-file=[read daemon-access password from file]:file:_files' \ + '--list-only[list the files instead of copying them]' \ + '(--only-write-batch)--write-batch=[write a batched update to the specified file]:file:_files' \ + '(--write-batch)--only-write-batch=[like --write-batch but w/o updating destination]:file:_files' \ + '--protocol=[force an older protocol version to be used]:number' \ + '--iconv=[request charset conversion of filenames]:number' \ + '--read-batch=[read a batched update from the specified file]:file:_files' +} + +_rsync "$@" diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh index eb5947ce0..0ec9c84a0 100644 --- a/Completion/Unix/Command/_ssh +++ b/Completion/Unix/Command/_ssh @@ -1,5 +1,11 @@ #compdef ssh slogin=ssh scp ssh-add ssh-agent ssh-keygen sftp +# Completions currently based on OpenSSH 5.9 (released on 2011-09-06). +# +# TODO: update ssh-keygen (not based on 5.9) +# TODO: sshd, ssh-keyscan, ssh-keysign + + _remote_files () { # There should be coloring based on all the different ls -F classifiers. local expl rempat remfiles remdispf remdispd args suf ret=1 @@ -10,7 +16,7 @@ _remote_files () { then rempat="${PREFIX%%[^./][^/]#}\*" else rempat="${(q)PREFIX%%[^./][^/]#}\*" fi - remfiles=(${(M)${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL "$rempat" 2>/dev/null)"}%%[^/]#(|/)}) + remfiles=(${(M)${(f)"$(_call_program files ssh -o BatchMode=yes $args -a -x ${IPREFIX%:} ls -d1FL -- "$rempat" 2>/dev/null)"}%%[^/]#(|/)}) compset -P '*/' compset -S '/*' || suf='remote file' @@ -38,79 +44,100 @@ _ssh () { typeset -A opt_args common=( - '-c+[select encryption cipher]:encryption cipher:(idea des 3des blowfish arcfour tss none)' - '-C[compress data]' - '-F+[specify alternate config file]:config file:_files' - '-i+[select identity file]:SSH identity file:_files' - '*-o+[specify extra options]:option string:->option' '(-2)-1[forces ssh to try protocol version 1 only]' '(-1)-2[forces ssh to try protocol version 2 only]' '(-6)-4[forces ssh to use IPv4 addresses only]' '(-4)-6[forces ssh to use IPv6 addresses only]' + '-C[compress data]' + '-c+[select encryption cipher]:encryption cipher:(idea des 3des blowfish arcfour tss none)' + '-F+[specify alternate config file]:config file:_files' + '-i+[select identity file]:SSH identity file:_files' + '*-o+[specify extra options]:option string:->option' + ) + common_transfer=( + '-l[limit used bandwidth]:bandwidth in KiB/s:' + '-P+[specify port on remote host]:port number on remote host' + '-p[preserve modification times, access times and modes]' + '-q[disable progress meter and warnings]' + '-r[recursively copy directories (follows symbolic links)]' + '-S+[specify ssh program]:path to ssh:_command_names -e' \ + '-v[verbose mode]' ) case "$service" in ssh) _arguments -C -s \ - '(-A)-a[disable forwarding of authentication agent connection]' \ '(-a)-A[enables forwarding of the authentication agent connection]' \ + '(-A)-a[disable forwarding of authentication agent connection]' \ '(-P)-b+[specify interface to transmit on]:bind address:_bind_addresses' \ - '-D+[specify a dynamic port forwarding]:port' \ + '-D+[specify a dynamic port forwarding]:[bind-address]\:port' \ '-e+[set escape character]:escape character (or `none'"'"'):' \ '(-n)-f[go to background]' \ '-g[allow remote hosts to connect to local forwarded ports]' \ - '-I+[specify smartcard device]:device:_files' \ - '-k[disable forwarding of kerberos tickets]' \ + '-I+[specify the PKCS#11 shared library to use]' \ + '-K[enable GSSAPI-based authentication and forwarding]' \ + '-k[disable forwarding of GSSAPI credentials]' \ + '*-L[specify local port forwarding]:local port forwarding:->forward' \ '-l+[specify login name]:login name:_ssh_users' \ + '-M[master mode for connection sharing]' \ '(-1)-m+[specify mac algorithms]:mac spec' \ + '(-1)-N[do not execute a remote command (protocol version 2 only)]' \ '-n[redirect stdin from /dev/null]' \ - '(-1)-N[do not execute a remote command. (protocol version 2 only)]' \ - '-p+[specify port on remote host]:port number on remote host' \ + '-O[control active connection multiplexing master process]:multiplex control command:(( + check\:"check that the master process is running" + forward\:"request forwardings without command execution" + cancel\:"cancel forwardings" + exit\:"request the master to exit" + stop\:"request the master to stop accepting further multiplexing requests"))' \ '-P[use non privileged port]' \ + '-p+[specify port on remote host]:port number on remote host' \ '(-v)*-q[quiet operation]' \ + '*-R[specify remote port forwarding]:remote port forwarding:->forward' \ + '-S+[specify location of control socket for connection sharing]:path to control socket:_files' \ '(-1)-s[invoke subsystem]' \ - '(-T)-t[force pseudo-tty allocation]' \ '(-1 -t)-T[disable pseudo-tty allocation (protocol version 2 only)]' \ - '(-q)*-v[verbose mode]' \ + '(-T)-t[force pseudo-tty allocation]' \ '-V[show version number]' \ - '(-X -Y)-x[disable X11 forwarding]' \ + '(-q)*-v[verbose mode]' \ + '(-N)-W[forward standard input/output over host:port (protocol version 2 only)]:host\:port' \ + '-w[request tunnel device forwarding with the specified tun devices]:local_tun[\:remote_tun]' \ '(-x -Y)-X[enable (untrusted) X11 forwarding]' \ + '(-X -Y)-x[disable X11 forwarding]' \ '(-x -X)-Y[enable trusted X11 forwarding]' \ - '-M[master mode for connection sharing]' \ - '-S+:path to control socket:_files' \ - '-O:multiplex control command:(check exit)' \ - '*-L[specify local port forwarding]:local port forwarding:->forward' \ - '*-R[specify remote port forwarding]:remote port forwarding:->forward' \ + '-y[send log information using the syslog module]' \ ':remote host name:->userhost' \ '*::args:->command' "$common[@]" && ret=0 ;; scp) _arguments -C -s \ - '-p[preserve modification times]' \ - '-r[recursively copy directories]' \ - '-v[verbose mode]' \ - '-B[batch mode]' \ - '-q[disables the progress meter]' \ - '-P+[specify port on remote host]:port number on remote host' \ - '-S+[specify ssh program]:path to ssh:_command_names -e' \ - '*:file:->file' "$common[@]" && ret=0 + '-3[copy through local host, not directly between the remote hosts]' \ + '-B[batch mode (don'"'"'t ask for passphrases)]' \ + '*:file:->file' "$common[@]" "$common_transfer[@]" && ret=0 ;; ssh-add) _arguments -s \ - '-l[list all identities]' \ - '-L[lists public key parameters of all identities in the agent]'\ - '-d[remove identity]' \ + '-c[identity is subject to confirmation via SSH_ASKPASS]' \ '-D[delete all identities]' \ - '-p[read passphrase from stdin]' \ + '-d[remove identity]' \ + '-e[remove keys provided by the PKCS#11 shared library]:library:' \ + '-k[load plain private keys only and skip certificates]' \ + '-L[lists public key parameters of all identities in the agent]'\ + '-l[list all identities]' \ + '-s[add keys provided by the PKCS#11 shared library]:library:' \ + '-t[set maximum lifetime for identity]:maximum lifetime (in seconds or time format):' \ + '-X[unlock the agent]' \ + '-x[lock the agent with a password]' \ '*:SSH identity file:_files' return ;; ssh-agent) _arguments -s \ - '(*)-k[kill agent automatically]' \ - '(-c)-s[force sh-style shell]' \ - '(-s)-c[force csh-style shell]' \ + '(-k)-a[UNIX-domain socket to bind agent to]:UNIX-domain socket:_files' \ + '(-k -s)-c[force csh-style shell]' \ '(-k)-d[debug mode]' \ + '-k[kill current agent]' \ + '(-k -c)-s[force sh-style shell]' \ + '-t[set default maximum lifetime for identities]:maximum lifetime (in seconds or time format):' \ '*::command: _normal' return ;; @@ -137,16 +164,12 @@ _ssh () { ;; sftp) _arguments -C -s \ - '-C[compress data]' \ - '-F+[specify alternate config file]:config file:_files' \ - '(-1)-s[invoke subsystem]' \ - '-S+[specify program]:program:_command_names -e' \ - '-B+[specify buffer size]:buffer size' \ + '-B+[specify buffer size]:buffer size in bytes (default\: 32768):' \ '-b+[specify batch file to read]:batch file:_files' \ - '*-v[verbose mode]' \ - '-1[forces ssh to try protocol version 1 only]' \ - '*-o+[specify extra options]:option string:->option' \ - '1:file:->rfile' '*:file:->file' && ret=0 + '-D[connect directly to a local sftp server]:sftp server path:' \ + '-R[specify number of outstanding requests]:number of requests (default\: 64):' \ + '-s[SSH2 subsystem or path to sftp server on the remote host]' \ + '1:file:->rfile' '*:file:->file' "$common[@]" "$common_transfer[@]" && ret=0 ;; esac @@ -163,22 +186,36 @@ _ssh () { ;; *(#i)ciphers*) _values -s , 'encryption cipher' \ - 'aes128-cbc' \ '3des-cbc' \ - 'blowfish-cbc' \ - 'cast128-cbc' \ - 'arcfour' \ + 'aes128-cbc' \ 'aes192-cbc' \ 'aes256-cbc' \ + 'aes128-ctr' \ + 'aes192-ctr' \ + 'aes256-ctr' \ + 'arcfour128' \ + 'arcfour256' \ + 'arcfour' \ + 'blowfish-cbc' \ + 'cast128-cbc' \ + \ 'rijndael128-cbc' \ 'rijndael192-cbc' \ 'rijndael256-cbc' \ - 'rijndael-cbc@lysator.liu.se' && ret=0 + 'rijndael-cbc@lysator.liu.se' \ + && ret=0 ;; *(#i)cipher*) - _wanted values expl 'encryption cipher' \ - compadd idea des 3des blowfish arcfour tss none && ret=0 + _wanted values expl 'encryption cipher (protocol version 1)' \ + compadd blowfish 3des des idea arcfour tss none && ret=0 ;; + *(#i)controlmaster*) + _wanted values expl 'truthish value' compadd yes no auto autoask && ret=0 + ;; + *(#i)controlpath*) + _description files expl 'path to control socket' + _files "$expl[@]" && ret=0 + ;; *(#i)globalknownhostsfile*) _description files expl 'global file with known hosts' _files "$expl[@]" && ret=0 @@ -193,6 +230,10 @@ _ssh () { *(#i)(local|remote)forward*) state=forward ;; + *(#i)preferredauthentications*) + _values -s , 'authentication method' gssapi-with-mic \ + hostbased publickey keyboard-interactive password && ret=0 + ;; *(#i)protocol*) _values -s , 'protocol version' \ '1' \ @@ -218,41 +259,95 @@ _ssh () { _description files expl 'xauth program' _files "$expl[@]" -g '*(-*)' && ret=0 ;; - *(#i)controlmaster*) - _wanted values expl 'truthish value' compadd yes no auto autoask && ret=0 - ;; - *(#i)controlpath*) - _description files expl 'path to control socket' - _files "$expl[@]" && ret=0 - ;; esac else + # old options are after the empty "\"-line _wanted values expl 'configure file option' \ compadd -M 'm:{a-z}={A-Z}' -qS '=' - \ - AddressFamily \ - AFSTokenPassing BatchMode BindAddress \ - ChallengeResponseAuthentication CheckHostIP \ - Cipher Ciphers ClearAllForwardings Compression \ - CompressionLevel ConnectionAttempts ConnectTimeout \ - ControlMaster ControlPath \ - DynamicForward EnableSSHKeysign \ - EscapeChar FallBackToRsh ForwardAgent ForwardX11 \ - ForwardX11Trusted \ - GatewayPorts GlobalKnownHostsFile GSSAPIAuthentication \ - GSSAPIDelegateCredentials HostbasedAuthentication \ - HostKeyAlgorithms HostKeyAlias HostName IdentityFile \ - IdentitiesOnly KbdInteractiveDevices \ - KeepAlive KerberosAuthentication KerberosTgtPassing \ - LocalForward LogLevel MACs NoHostAuthenticationForLocalhost \ - NumberOfPasswordPrompts PreferredAuthentications \ - PasswordAuthentication Port Protocol ProtocolKeepAlives \ - ProxyCommand PubkeyAuthentication RemoteForward \ - RhostsAuthentication RhostsRSAAuthentication \ - RSAAuthentication ServerAliveInterval ServerAliveCountMax \ - SetupTimeOut SmartcardDevice StrictHostKeyChecking \ - TCPKeepAlive \ - UsePrivilegedPort User UserKnownHostsFile UseRsh \ - VerifyHostKeyDNS XAuthLocation && ret=0 + AddressFamily \ + BatchMode \ + BindAddress \ + ChallengeResponseAuthentication \ + CheckHostIP \ + Cipher \ + Ciphers \ + ClearAllForwardings \ + Compression \ + CompressionLevel \ + ConnectionAttempts \ + ConnectTimeout \ + ControlMaster \ + ControlPath \ + ControlPersist \ + DynamicForward \ + EnableSSHKeysign \ + EscapeChar \ + ExitOnForwardFailure \ + ForwardAgent \ + ForwardX11 \ + ForwardX11Timeout \ + ForwardX11Trusted \ + GatewayPorts \ + GlobalKnownHostsFile \ + GSSAPIAuthentication \ + GSSAPIDelegateCredentials \ + HashKnownHosts \ + Host \ + HostbasedAuthentication \ + HostKeyAlgorithms \ + HostKeyAlias \ + HostName \ + IdentitiesOnly \ + IdentityFile \ + IPQoS \ + KbdInteractiveAuthentication \ + KbdInteractiveDevices \ + KexAlgorithms \ + LocalCommand \ + LocalForward \ + LogLevel \ + MACs \ + NoHostAuthenticationForLocalhost \ + NumberOfPasswordPrompts \ + PasswordAuthentication \ + PermitLocalCommand \ + PKCS11Provider \ + Port \ + PreferredAuthentications \ + Protocol \ + ProxyCommand \ + PubkeyAuthentication \ + RekeyLimit \ + RemoteForward \ + RequestTTY \ + RhostsRSAAuthentication \ + RSAAuthentication \ + SendEnv \ + ServerAliveCountMax \ + ServerAliveInterval \ + StrictHostKeyChecking \ + TCPKeepAlive \ + Tunnel \ + TunnelDevice \ + UsePrivilegedPort \ + User \ + UserKnownHostsFile \ + VerifyHostKeyDNS \ + VisualHostKey \ + XAuthLocation \ + \ + AFSTokenPassing \ + FallBackToRsh \ + KeepAlive \ + KerberosAuthentication \ + KerberosTgtPassing \ + PreferredAuthentications \ + ProtocolKeepAlives \ + RhostsAuthentication \ + SetupTimeOut \ + SmartcardDevice \ + UseRsh \ + && ret=0 fi ;; forward) diff --git a/Completion/Unix/Command/_systemctl b/Completion/Unix/Command/_systemctl new file mode 100644 index 000000000..69adcf775 --- /dev/null +++ b/Completion/Unix/Command/_systemctl @@ -0,0 +1,305 @@ +#compdef systemctl + +# Copyright (c) 2011 Foudil Brétel <foudil.newbie+zshsystemctl@gmail.com> +# +# This file is released under the GPLv3. +# +# inspired from _yum and systemctl-bash-completion.sh (shipped with systemctl) +# +# TODO: enable options after commands. Ex: systemctl list-units --all --full + +# Main dispatcher +_systemctl() +{ + local curcontext="$curcontext" state lstate line + + # -s for aggregated options like -aP + _arguments -s \ + {-h,--help}'[Show help]' \ + '--version[Show package version]' \ + {-t,--type=}'[List only units of a particular type]:unit type:(automount device mount path service snapshot socket swap target timer)' \ + \*{-p,--property=}'[Show only properties by specific name]:unit property:' \ + {-a,--all}'[Show all units/properties, including dead/empty ones]' \ + '--failed[Show only failed units]' \ + "--full[Don't ellipsize unit names on output]" \ + '--fail[When queueing a new job, fail if conflicting jobs are pending]' \ + '--ignore-dependencies[When queueing a new job, ignore all its dependencies]' \ + '--kill-mode=[How to send signal]:killmode:(control-group process)' \ + '--kill-who=[Who to send signal to]:killwho:(main control all)' \ + {-s,--signal=}'[Which signal to send]:signal:_signals' \ + {-H,--host=}'[Show information for remote host]:userathost:_hosts_or_user_at_host' \ + {-P,--privileged}'[Acquire privileges before execution]' \ + {-q,--quiet}'[Suppress output]' \ + '--no-block[Do not wait until operation finished]' \ + "--no-wall[Don't send wall message before halt/power-off/reboot]" \ + "--no-reload[When enabling/disabling unit files, don't reload daemon configuration]" \ + '--no-legend[Do not print a legend, i.e. the column headers and the footer with hints]' \ + '--no-pager[Do not pipe output into a pager]' \ + '--no-ask-password[Do not ask for system passwords]' \ + '--order[When generating graph for dot, show only order]' \ + '--require[When generating graph for dot, show only requirement]' \ + '--system[Connect to system manager]' \ + '--user[Connect to user service manager]' \ + '--global[Enable/disable unit files globally]' \ + {-f,--force}'[When enabling unit files, override existing symlinks. When shutting down, execute action immediately]' \ + '--defaults[When disabling unit files, remove default symlinks only]' \ + '*::systemctl command:_systemctl_command' +} + +_hosts_or_user_at_host() +{ + _alternative \ + 'users-hosts:: _user_at_host' \ + 'hosts:: _hosts' +} + +(( $+functions[_systemctl_command] )) || _systemctl_command() +{ + local -a _systemctl_cmds + _systemctl_cmds=( + "list-units:List units" + "start:Start (activate) one or more units" + "stop:Stop (deactivate) one or more units" + "reload:Reload one or more units" + "restart:Start or restart one or more units" + "condrestart:Restart one or more units if active" + "try-restart:Restart one or more units if active" + "reload-or-restart:Reload one or more units is possible, otherwise start or restart" + "force-reload:Reload one or more units is possible, otherwise restart if active" + "reload-or-try-restart:Reload one or more units is possible, otherwise restart if active" + "isolate:Start one unit and stop all others" + "kill:Send signal to processes of a unit" + "is-active:Check whether units are active" + "status:Show runtime status of one or more units" + "show:Show properties of one or more units/jobs or the manager" + "reset-failed:Reset failed state for all, one, or more units" + "enable:Enable one or more unit files" + "disable:Disable one or more unit files" + "is-enabled:Check whether unit files are enabled" + "load:Load one or more units" + "list-jobs:List jobs" + "cancel:Cancel all, one, or more jobs" + "monitor:Monitor unit/job changes" + "dump:Dump server status" + "dot:Dump dependency graph for dot(1)" + "snapshot:Create a snapshot" + "delete:Remove one or more snapshots" + "daemon-reload:Reload systemd manager configuration" + "daemon-reexec:Reexecute systemd manager" + "show-environment:Dump environment" + "set-environment:Set one or more environment variables" + "unset-environment:Unset one or more environment variables" + "default:Enter system default mode" + "rescue:Enter system rescue mode" + "emergency:Enter system emergency mode" + "halt:Shut down and halt the system" + "poweroff:Shut down and power-off the system" + "reboot:Shut down and reboot the system" + "kexec:Shut down and reboot the system with kexec" + "exit:Ask for user instance termination" + ) + + if (( CURRENT == 1 )); then + _describe -t commands 'systemctl command' _systemctl_cmds || compadd "$@" + else + local curcontext="$curcontext" + + cmd="${${_systemctl_cmds[(r)$words[1]:*]%%:*}}" + # Deal with any aliases + case $cmd in + condrestart) cmd="try-restart";; + force-reload) cmd="reload-or-try-restart";; + esac + + if (( $#cmd )); then + curcontext="${curcontext%:*:*}:systemctl-${cmd}:" + + local update_policy + zstyle -s ":completion:${curcontext}:" cache-policy update_policy + if [[ -z "$update_policy" ]]; then + zstyle ":completion:${curcontext}:" cache-policy _systemctl_caching_policy + fi + + _call_function ret _systemctl_$cmd || _message 'no more arguments' + else + _message "unknown systemctl command: $words[1]" + fi + return ret + fi +} + +__check_option_nolegend() +{ + systemctl --no-legend --version 2>&1 | grep -q 'unrecognized option' + print -Pn '%(?..--no-legend)' +} +nolegend=$(__check_option_nolegend) + + +# Fills the unit lists +_systemctl_all_units() +{ + if ( [[ ${+_sys_all_units} -eq 0 ]] || _cache_invalid SYS_ALL_UNITS ) && + ! _retrieve_cache SYS_ALL_UNITS; + then + _sys_all_units=( $(systemctl ${nolegend} list-units --full --all \ + | cut -d' ' -f1 2>/dev/null) ) + _store_cache SYS_ALL_UNITS _sys_all_units + fi +} + +_systemctl_inactive_units() +{ + _sys_inactive_units=( $(systemctl ${nolegend} list-units --full --all \ + | awk '$3 != "active" {print $1}' 2>/dev/null) ) +} + +_systemctl_active_units() +{ + _sys_active_units=( $(systemctl ${nolegend} list-units --full \ + | cut -d' ' -f1 2>/dev/null) ) +} + +_systemctl_failed_units() +{ + _sys_failed_units=( $(systemctl ${nolegend} list-units --full --failed \ + | cut -d' ' -f1 2>/dev/null) ) +} + +_filter_units_by_property () { + local property=$1 value=$2 ; shift ; shift + local -a units ; units=($*) + local -a props ; props=( $(systemctl show --property "$property" -- \ + ${units[*]} | grep -v '^$') ) + for ((i=1; $i <= ${#units[*]}; i++)); do + if [[ "${props[i]}" = "$property=$value" ]]; then + echo "${units[i]}" + fi + done +} + +# Completion functions for ALL_UNITS +for fun in enable disable is-active is-enabled status show ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_all_units + compadd "$@" -a - _sys_all_units + } +done + +# Completion functions for STARTABLE_UNITS +(( $+functions[_systemctl_start] )) || _systemctl_start() +{ + _systemctl_inactive_units + compadd "$@" - $( _filter_units_by_property CanStart yes \ + ${_sys_inactive_units[*]} | grep -Ev '\.(device|snapshot)$' ) +} + +# Completion functions for RESTARTABLE_UNITS +for fun in restart reload-or-restart ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_all_units + compadd "$@" - $( _filter_units_by_property CanStart yes \ + ${_sys_all_units[*]} | grep -Ev '\.(device|snapshot|socket|timer)$' ) + } +done + +# Completion functions for STOPPABLE_UNITS +for fun in stop kill try-restart condrestart ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_active_units + compadd "$@" - $( _filter_units_by_property CanStop yes \ + ${_sys_active_units[*]} ) + } +done + +# Completion functions for RELOADABLE_UNITS +for fun in reload reload-or-try-restart force-reload ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + _systemctl_active_units + compadd "$@" - $( _filter_units_by_property CanReload yes \ + ${_sys_active_units[*]} ) + } +done + +# Completion functions for ISOLATABLE_UNITS +(( $+functions[_systemctl_isolate] )) || _systemctl_isolate() +{ + _systemctl_all_units + compadd "$@" - $( _filter_units_by_property AllowIsolate yes \ + ${_sys_all_units[*]} ) +} + +# Completion functions for FAILED_UNITS +(( $+functions[_systemctl_reset-failed] )) || _systemctl_reset-failed() +{ + _systemctl_failed_units + compadd "$@" -a - _sys_failed_units || _message "no failed-unit found" +} + +# Completion functions for JOBS +(( $+functions[_systemctl_cancel] )) || _systemctl_cancel() +{ + compadd "$@" - $(systemctl ${nolegend} list-jobs \ + | cut -d' ' -f1 2>/dev/null ) || _message "no job found" +} + +# Completion functions for SNAPSHOTS +(( $+functions[_systemctl_delete] )) || _systemctl_delete() +{ + compadd "$@" - $(systemctl ${nolegend} list-units --type snapshot --full \ + --all | cut -d' ' -f1 2>/dev/null ) || _message "no snampshot found" +} + +# Completion functions for ENVS +for fun in set-environment unset-environment ; do + (( $+functions[_systemctl_$fun] )) || _systemctl_$fun() + { + local fun=$0 ; fun=${fun##_systemctl_} + local suf + if [[ "${fun}" = "set-environment" ]]; then + suf='-S=' + fi + + compadd "$@" ${suf} - $(systemctl show-environment \ + | sed 's_\([^=]\+\)=.*_\1_' ) + } +done + +# no completion for: +# [STANDALONE]='daemon-reexec daemon-reload default dot dump emergency exit +# halt kexec list-jobs list-units monitor poweroff reboot +# rescue show-environment' +# [NAME]='snapshot load' + +_systemctl_caching_policy() +{ + local _sysunits + local -a oldcache + + # rebuild if cache is more than a day old + oldcache=( "$1"(mh+1) ) + (( $#oldcache )) && return 0 + + _sysunits=($(systemctl ${nolegend} --full --all | cut -d' ' -f1)) + + if (( $#_sysunits )); then + for unit in $_sysunits; do + [[ "$unit" -nt "$1" ]] && return 0 + done + fi + + return 1 +} + +_systemctl "$@" + +# Local Variables: +# mode: sh +# sh-indentation: 2 +# indent-tabs-mode: nil +# sh-basic-offset: 2 +# End: diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux index e9977fbbd..5fb721960 100644 --- a/Completion/Unix/Command/_tmux +++ b/Completion/Unix/Command/_tmux @@ -1520,6 +1520,10 @@ function _tmux() { _describe -t subcommands 'tmux commands and aliases' _tmux_commands -- _tmux_aliases fi else + if (( ${+commands[tmux]} == 0 )); then + _message '`tmux'\'' not found in $path; sub-cmd completions disabled.' + return 0 + fi tmuxcommand="${words[1]}" if [[ -n ${_tmux_aliasmap[$tmuxcommand]} ]] ; then tmuxcommand="${_tmux_aliasmap[$tmuxcommand]}" diff --git a/Completion/Unix/Command/_tree b/Completion/Unix/Command/_tree new file mode 100644 index 000000000..d759409b5 --- /dev/null +++ b/Completion/Unix/Command/_tree @@ -0,0 +1,51 @@ +#compdef tree + +# Completions for tree, version 1.5.3 +# Tree is available at +# http://mama.indstate.edu/users/ice/tree/ + +typeset -a opts + +opts=( +'--help[verbose usage listing]' +'--version[version of tree]' +'-a[show all files, including hidden ones]' +'-d[list directories only]' +'-f[print full path prefix for each file]' +'-i[do not print indentation lines]' +'-l[follow symlinks that point to directories]' +'-x[stay on current filesystem]' +'-P[list only files matching a pattern]:pattern:' +'-I[do not list files matching a pattern]:pattern:' +'--noreport[do not print file and directory report at end]' +'-p[print file type and permissions, like ls -l]' +'-s[print size of each file in bytes]' +'-h[print human readable file size]' +'-u[print username]' +'-g[print group name]' +'-D[print date of last modification]' +'--inodes[print inode numbers]' +'--device[print device number to which file or directory belongs]' +'-F[append descriptive character to end, like ls -F]' +'-q[print non-printable characters as question mark, not caret]' +'-N[print non-printable characters as is, not as caret]' +'-v[sort the output as version]' +'-r[sort output in reverse alphabetic order]' +'-t[sort output by last modification time instead of alphabetically]' +'--dirsfirst[list directories before files]' +'-n[turn colorization off always, over-ridden by the -C option]' +'-C[turn colorization on always]' +'-A[turn on ANSI line graphics hack when printing indentation lines]' +'-S[turn on ASCII line graphics]' +'-L[max display depth of tree]:level:' +'--filelimit[do not descend directories with more than number of entries]:number:' +'-R[recursively cross down the tree and execute tree again]' +'-H[turn on HTML output]' +'-T[title for HTML output]' +'--charset[character set for HTML and for line drawing]:charset:' +'--nolinks[turn off hyperlinks in HTML output]' +'-o[send output to file]:filename:_files' +'*:directory:_files -/' +) + +_arguments $opts diff --git a/Completion/Unix/Command/_twidge b/Completion/Unix/Command/_twidge new file mode 100644 index 000000000..d8b3b3def --- /dev/null +++ b/Completion/Unix/Command/_twidge @@ -0,0 +1,77 @@ +#compdef twidge +## completion for twidge 1.0.8, based on twidge(1) + +function _twidge_command { + typeset -a twidge_commands + typeset -i skip=1 + + twidge lscommands | while read cmd desc; do + if [[ $cmd == ---* ]] { + skip=0 + continue + } + if (( skip )) { + continue + } + twidge_commands+="${cmd}:${desc}" + done + + _describe command twidge_commands +} + +function _twidge_args { + typeset -a args_common args_more args_other args_update + + args_common=( + '(-a --all)'{-a,--all}'[receive all content]' + '(-e --exec)'{-e,--exec}'[execute command for each retrieved item]:command' + '(-l --long)'{-l,--long}'[long output format]' + '(-m --mailto)'{-m,--mailto}'[mail retrieved items]:mail address' + ) + + args_more=( + '(-s --saveid)'{-s,--saveid}'[save ID of most recent message]' + '(-u --unseen)'{-u,--unseen}'[only show unseen messages]' + ) + + args_other=( + '(-U --username)'{-U,--username}'[show updates of different user]:username' + ) + + args_update=( + '(-i --inreplyto)'{-i,--inreplyto}'[update in reply to a message]:message id' + '(-i --inreplyto 1)-r[read RFC2822 Mail]' + ':status' + ) + + case ${words[1]} in + lsarchive) + _arguments $args_common $args_more $args_other + ;; + ls(dm(|archive)|recent|replies|rt(|archive|replies))) + _arguments $args_common $args_more + ;; + lsfollow(ers|ing)) + _arguments $args_common :username + ;; + dmsend) + _arguments :recipient :status + ;; + (un|)follow) + _message username + ;; + update) + _arguments $args_update + ;; + esac +} + +function _twidge { + _arguments \ + '(-c --config)'{-c,--config}'[config file]:file:_files' \ + '(-d --debug)'{-d,--debug}'[enable debugging output]' \ + '(-): :_twidge_command' \ + '(-)*:: :_twidge_args' +} + +_twidge "$@" diff --git a/Completion/Unix/Command/_unison b/Completion/Unix/Command/_unison index bb8edd489..5725575c5 100644 --- a/Completion/Unix/Command/_unison +++ b/Completion/Unix/Command/_unison @@ -42,7 +42,7 @@ _arguments \ '-copythreshold[use copyprog on files bigger than this]:size (kb):' \ '-debug:debug module:(all verbose)' \ '-diff[command for showing differences between files]:program:_files -g "*(-x)"' \ - '-dontchmod[When set, never use the chmod system call]' \ + '-dontchmod[when set, never use the chmod system call]' \ '-dumbtty[do not change terminal settings in text UI]' \ '-fastcheck:fast update detection:(true false default)' \ '-forcepartial[add a pattern to the forcepartial list]:pattern:' \ @@ -63,7 +63,7 @@ _arguments \ '-mountpoint[abort if this path does not exist]:mountpoint:_files -/' \ '-numericids[dont map uid/gid values by user/group names]' \ '-preferpartial[add a pattern to the preferpartial list]:pattern:' \ - '-pretendwin[Use creation times for detecting updates]' \ + '-pretendwin[use creation times for detecting updates]' \ '-repeat[synchronize repeatedly (text interface only)]:repeat:' \ '-retry[re-try failed synchronizations N times (text ui only)]:retry times:' \ '-rootalias[register alias for canonical root names]:root alias:' \ diff --git a/Completion/Unix/Command/_vim b/Completion/Unix/Command/_vim index af5afd347..7aec1ecf7 100644 --- a/Completion/Unix/Command/_vim +++ b/Completion/Unix/Command/_vim @@ -12,6 +12,9 @@ _vim_files () { esac } +local curcontext="$curcontext" state line expl +typeset -A opt_args + local arguments arguments=( @@ -46,7 +49,7 @@ arguments=( {-r,-L}'[list swap files and exit or recover from a swap file]::swap file:_vim_files -g \*.sw\?' '( -H -F)-A[start in Arabic mode]' '(-A -F)-H[start in Hebrew mode]' - '(-A -H )-H[start in Farsi mode]' + '(-A -H )-F[start in Farsi mode]' '-T[set terminal type]:::_terminals' '-u[use given vimrc file instead of default .vimrc]::rc file:_files' '-U[use given gvimrc file instead of default .gvimrc]::rc file:_files' @@ -54,7 +57,7 @@ arguments=( '-o-[number of windows to open (default: one for each file)]::window count: ' '-O-[number of windows to vertically split open (default is one for each file)]::window count: ' '-p-[number of tabs to open (default: one for each file)]::tab count: ' - '-q-[quickfix file]:*:file:_vim_files' + '(* -t)-q-[quickfix file]:*:file:_vim_files' '*--cmd[execute given command before loading any RC files]:command: ' '-c[execute given command after loading the first file]:command: ' '-S[source a session file after loading the first file]:session file:_files' @@ -76,14 +79,22 @@ arguments=( '--echo-wid[echo window ID on STDOUT, GUI version only]' '--literal[do not expand wildcards in arguments (this is useless with ZSH)]' '(- *)--serverlist[list available vim servers and exit]' - '--servername[name of vim server to send to or name of server to become]:server name: ' + '--servername[name of vim server to send to or name of server to become]:server name:->server' '--startuptime[write startup timing messages to given file]:log file:_files' '--socketid[run GVIM in another window]' '-i[use given viminfo file instead of default .viminfo]:viminfo file:_files' '(- *)'{-h,--help}'[print help and exit]' '(- *)--version[print version information and exit]' - '(*)-t[edit file where tag is defined]:tag:_complete_tag' - '(-t)*:file:_vim_files' + '(* -q)-t[edit file where tag is defined]:tag:_complete_tag' + '(-t -q)*:file:_vim_files' ) -_arguments -S $arguments +_arguments -C -S $arguments && return + +if [[ "$state" = server ]]; then + local -a servers + servers=( ${(f)"$(_call_program servers $words[1] --serverlist 2>/dev/null)"} ) + _wanted servers expl server compadd -M 'm:{a-z}={A-Z}' -a servers && return +fi + +return 1 diff --git a/Completion/Unix/Command/_wget b/Completion/Unix/Command/_wget index 54c09a377..e54a08b27 100644 --- a/Completion/Unix/Command/_wget +++ b/Completion/Unix/Command/_wget @@ -21,6 +21,7 @@ _arguments -C -s \ '--retry-connrefused[retry even if connection is refused]' \ '(--output-document -O)'{--output-document=,-O+}'[specify file to write documents to]:output file:_files' \ '(--continue -c)'{--continue,-c}'[continue getting an existing file]' \ + '--content-disposition[honor the Content-Disposition header when choosing local file names]' \ '--progress=[set progress gauge type]:gauge type:->gauge' \ '(--timestamping -N)'{--timestamping,-N}'[retrieve only files newer than existing]' \ '(--server-response -S)'{--server-response,-S}'[print server response]' \ diff --git a/Completion/Unix/Type/_path_files b/Completion/Unix/Type/_path_files index 858fe3f74..a170983ba 100644 --- a/Completion/Unix/Type/_path_files +++ b/Completion/Unix/Type/_path_files @@ -438,8 +438,19 @@ for prepath in "$prepaths[@]"; do tmp2=( "$tmp1[@]" ) - if [[ "$tpre$tsuf" = */* ]]; then - compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake + if [[ "$tpre$tsuf" = (#b)*/(*) ]]; then + + # We are going to be looping over the leading path segments. + # This means we should not apply special-dirs handling unless + # the path tail is a fake directory that needs to be simulated, + # and we should not apply pattern matching until we are looking + # for files rather than for intermediate directories. + + if [[ -n "$fake${match[1]}" ]]; then + compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake + else + compfiles -P$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" '' fake + fi elif [[ "$sopt" = *[/f]* ]]; then compfiles -p$cfopt tmp1 accex "$skipped" "$_matcher $matcher[2]" "$sdirs" fake "$pats[@]" else diff --git a/Completion/Unix/Type/_pdf b/Completion/Unix/Type/_pdf index a2fbbc552..a2601997b 100644 --- a/Completion/Unix/Type/_pdf +++ b/Completion/Unix/Type/_pdf @@ -1,4 +1,4 @@ -#compdef pdf2dsc pdf2ps pdfimages pdfinfo pdftopbm pdftops pdftotext pdfopt pdffonts kpdf +#compdef pdf2dsc pdf2ps pdfimages pdfinfo pdftopbm pdftops pdftotext pdfopt pdffonts kpdf apvlv local expl ext='' diff --git a/Completion/Unix/Type/_perl_modules b/Completion/Unix/Type/_perl_modules index 26cab0c23..1b61043e7 100644 --- a/Completion/Unix/Type/_perl_modules +++ b/Completion/Unix/Type/_perl_modules @@ -101,7 +101,7 @@ _perl_modules () { # Find all modules if [[ -d $libdir && -x $libdir ]]; then - new_pms=( $libdir/{[A-Z]*/***/,}*${~sufpat}~*blib* ) + new_pms=( $libdir/{[A-Za-z]*/***/,}*${~sufpat}~*blib* ) new_pms=( "${(@)new_pms##$libdir/##}" ) fi |