diff options
Diffstat (limited to 'Completion/Unix/Command')
31 files changed, 1200 insertions, 643 deletions
diff --git a/Completion/Unix/Command/_adb b/Completion/Unix/Command/_adb index e687762d3..88aca2464 100644 --- a/Completion/Unix/Command/_adb +++ b/Completion/Unix/Command/_adb @@ -76,7 +76,8 @@ _adb() { '(-d -e )-s[serial]: :_adb_device_serial' \ '( -e -s)-d[device]' \ '(-d -s)-e[emulator]' \ - '*:"options":_adb_options_handler' + '1:"options":_adb_options_handler' \ + '*: : _default' return; } @@ -99,27 +100,30 @@ _adb_dispatch_command () { fi case ${curcontext} in - (*:adb:shell) + (*:adb-shell) (( $+functions[_adb_dispatch_shell] )) && _adb_dispatch_shell ;; - (*:adb:connect|*:adb:disconnect) + (*:adb-connect|*:adb-disconnect) (( $+functions[_adb_dispatch_connection_handling] )) && _adb_dispatch_connection_handling ;; - (*:adb:logcat) + (*:adb-logcat) (( $+functions[_adb_dispatch_logcat] )) && _adb_dispatch_logcat ;; - (*:adb:push) + (*:adb-push) (( $+functions[_adb_dispatch_push] )) && _adb_dispatch_push ;; - (*:adb:pull) + (*:adb-pull) (( $+functions[_adb_dispatch_pull] )) && _adb_dispatch_pull ;; - (*:adb:install) + (*:adb-install) (( $+functions[_adb_dispatch_install] )) && _adb_dispatch_install ;; - (*:adb:uninstall) + (*:adb-uninstall) (( $+functions[_adb_dispatch_uninstall] )) && _adb_dispatch_uninstall ;; + (*:adb-*) + _default + ;; (*) _arguments \ '(-d -e)-s["serial"]: :_adb_device_serial' \ @@ -143,7 +147,7 @@ _adb_sanitize_context () { done ##expand unquoted to remove sparse elements mywords=( ${mywords[@]} ) - curcontext="${curcontext}${mywords[-1]}" + (( $#mywords )) && curcontext="${curcontext%:*}-${mywords[-1]}:" } (( $+functions[_adb_device_specification] )) || @@ -373,9 +377,9 @@ _adb_dispatch_connection_handling () { fi } -(( $+functions[adb_check_log_redirect] )) || +(( $+functions[_adb_check_log_redirect] )) || _adb_check_log_redirect () { - LOG_REDIRECT=${$(adb ${=ADB_DEVICE_SPECIFICATION} shell getprop log.redirect-stdio)// + LOG_REDIRECT=${$(adb ${=ADB_DEVICE_SPECIFICATION} shell getprop log.redirect-stdio 2>/dev/null)// /} [[ ${LOG_REDIRECT[1,4]} == "true" ]] && _message -r "Notice: stdio log redirection enabled on the device, so some completions will not work" } diff --git a/Completion/Unix/Command/_beep b/Completion/Unix/Command/_beep new file mode 100644 index 000000000..c49c09726 --- /dev/null +++ b/Completion/Unix/Command/_beep @@ -0,0 +1,50 @@ +#compdef _beep + +# beep [--verbose | --debug] [-e device | --device device] [-f N] [-l N] +# [-r N] [-d N] [-D N] [-s] [-c] +# beep [ OPTIONS ] [-n] [--new] [ OPTIONS ] +# beep [-h] [--help] +# beep [-v] [-V] [--version] + +# We support the -n/--new restart flag, when it is in its own word, by +# stripping all words from the command line that are after the first -n +# following words[CURRENT] or before the first -n preceding it. As far as +# _arguments knows, the -n flag does not exist, and argv should specify +# a single beeping specification. + +## Strip $words[2] through the first -n preceding $words[CURRENT]. +integer specstart +while specstart=$words[(i)(-n|--new)] + (( specstart < CURRENT )) +do + words[2,specstart]=() + (( CURRENT -= specstart - 1)) +done +unset specstart + +## Strip everything in $words after the first -n following $words[CURRENT]. +integer specend +while specend=$words[(I)(-n|--new)] + (( specend > CURRENT )) +do + words[specend,$#words]=() +done +unset specend + +local -a args +args=( + "(--verbose --debug)"{--verbose,--debug}"[enable debug output]" + "(-e --device)"{-e+,--device=}"[specify device to use]:device (default /dev/tty0, /dev/vc/0)" + "-f+:frequency (Hz) as integer or float" + "-l+:duration (ms)" + "-r+:number of repetitions" + "(-D)-d+[delay between beeps]:delay (ms)" + "(-d)-D+[delay after each beep]:delay (ms)" + "(-n --new)"{-n,--new}"[start a new beeping specification]" + "-s[cat, and beep after each line]" + "-c[cat, and beep after each character]" + "(-)"{-h,--help}"[display usage info]" + "(-)"{-v,-V,--version}"[display version info]" +) + +_arguments -s -S -w : $args diff --git a/Completion/Unix/Command/_clay b/Completion/Unix/Command/_clay index 71f05bf64..581338b8b 100644 --- a/Completion/Unix/Command/_clay +++ b/Completion/Unix/Command/_clay @@ -38,5 +38,5 @@ _arguments -C \ "-e:compile and run <source> (implies -run)" \ "-M-:import <module>.*; for -e" \ "-v[display version info]" \ - ":program file:_files -g '*.clay'" + ":program file:_files -g '*.clay(-.)'" diff --git a/Completion/Unix/Command/_du b/Completion/Unix/Command/_du index d8871cd8d..4065a20de 100644 --- a/Completion/Unix/Command/_du +++ b/Completion/Unix/Command/_du @@ -74,5 +74,5 @@ else do [[ $OSTYPE = $~pattern ]] && args+=( $arg ) done - _arguments -s -A "-*" $args + _arguments -s -A "-*" $args '*:file:_files' fi diff --git a/Completion/Unix/Command/_find b/Completion/Unix/Command/_find index 8f80e36cf..e736f32cb 100644 --- a/Completion/Unix/Command/_find +++ b/Completion/Unix/Command/_find @@ -1,6 +1,7 @@ #compdef find gfind -local variant args +local curcontext="$curcontext" state_descr variant +local -a state line args alts _pick_variant -r variant gnu=GNU $OSTYPE -version @@ -26,12 +27,12 @@ case $variant in '*-print0' ) ;| + solaris*|freebsd*|dragonfly*|darwin*|gnu) + args+=( '*-mount' ) + ;| netbsd*|freebsd*|dragonfly*|darwin*|gnu) args+=( '(-H -L)-P[never follow symlinks]' ) ;| - netbsd*|freebsd*|dragonfly*|openbsd*|darwin*|gnu) - args+=( '-d[depth first traversal]' ) - ;| darwin*|freebsd*|gnu) args+=( '*-Bmin:birth time (minutes)' @@ -39,11 +40,13 @@ case $variant in '*-Btime:birth time (hours)' ) ;| - freebsd*|dragonfly*|darwin*|openbsd*|gnu) + netbsd*|freebsd*|dragonfly*|openbsd*|darwin*|gnu) args+=( + '-d[depth first traversal]' '*-anewer:file to compare (access time):_files' '*-cnewer:file to compare (inode change time):_files' - '*-mnewer:file to compare (modification time):_files' + '*-empty' + '*-execdir:program: _command_names -e:*\;::program arguments: _normal' '*-maxdepth:maximum search depth' '*-mindepth:minimum search depth' '*-path:path pattern to search:' @@ -52,8 +55,6 @@ case $variant in freebsd*|dragonfly*|darwin*|gnu) args+=( '*-delete' - '*-empty' - '*-execdir:program: _command_names -e:*\;::program arguments: _normal' '*-gid:numeric group ID' '*-uid:numeric user ID' '*-noleaf' @@ -65,6 +66,7 @@ case $variant in '*-wholename:full path pattern to search' \ '*-iwholename:full path pattern to search (case insensitive)' '*-ignore_readdir_race' + '*-mnewer:file to compare (modification time):_files' '*-noignore_readdir_race' '*-okdir:program: _command_names -e:*\;::program arguments: _normal' '*-samefile:file to compare inode:_files' \ @@ -79,9 +81,13 @@ case $variant in netbsd*|freebsd*|dragonfly*|darwin*) args+=( '-E[use extended regular expressions with -regex/-iregex]' + '-s[traverse directories in sorted order]' + ) + ;| + netbsd*|freebsd*|dragonfly*|openbsd*|darwin*) + args+=( '-X[warn if filename contains characters special to xargs]' '-f[specify file hierarchy to traverse]:path:_directories' - '-s[traverse directories in sorted order]' "-x[don't span filesystems]" '*-flags:flags:_chflags' ) @@ -114,11 +120,11 @@ case $variant in ;; esac -_arguments $args \ +_arguments -C $args \ '(-L -P)-H[only follow symlinks when resolving command-line arguments]' \ '(-H -P)-L[follow symlinks]' \ - '*-atime:access time (days)' \ - '*-ctime:inode change time (days)' \ + '*-atime:access time (days):->times' \ + '*-ctime:inode change time (days):->times' \ '*-depth' \ '*-exec:program: _command_names -e:*\;::program arguments: _normal' \ '*-follow' \ @@ -127,8 +133,7 @@ _arguments $args \ '*-inum:inode number:' \ '*-links:number of links:' \ '*-ls' \ - '*-mount' \ - '*-mtime:modification time (days)' \ + '*-mtime:modification time (days):->times' \ '*-name:name pattern' \ '*-newer:file to compare (modification time):_files' \ '*-nogroup' \ @@ -143,3 +148,13 @@ _arguments $args \ '*-xdev' \ '*-a' '*-o' \ '*:directory:_files -/' + +if [[ $state = times ]]; then + if ! compset -P '[+-]' || [[ -prefix '[0-9]' ]]; then + disp=( 'before' 'exactly' 'since' ) + compstate[list]+=' packed' + alts=( "senses:sense:compadd -V times -S '' -d disp - + '' -" ) + fi + alts+=( "times:${state_descr}:_dates -f d" ) + _alternative $alts +fi diff --git a/Completion/Unix/Command/_gdb b/Completion/Unix/Command/_gdb index 48c9d654f..e9c333925 100644 --- a/Completion/Unix/Command/_gdb +++ b/Completion/Unix/Command/_gdb @@ -5,17 +5,19 @@ local cur="$words[CURRENT]" prev w list ret=1 expl [[ "$PREFIX" = --* ]] && _arguments -- '*=(CORE|SYM)FILE:core file:_files' \ '*=EXECFILE:executable:_files -g \*\(-\*\)' \ - '*=TTY:terminal device:compadd /dev/tty\*' && return 0 + '*=TTY:terminal device:_ttys' && return 0 if compset -P '-(cd|directory)='; then _files -/ elif compset -P '-tty='; then - _wanted devices expl 'terminal device' compadd - /dev/tty* + _wanted devices expl 'terminal device' _ttys elif compset -P '-(exec|se)='; then _description files expl executable _files "$expl[@]" -g '*(-*)' elif compset -P '-(symbols|core|command)='; then _files +elif compset -P '--pid='; then + _pids elif [[ "$PREFIX" = -* ]]; then _tags options while _tags; do @@ -47,7 +49,7 @@ else done if [[ $#w -gt 1 ]]; then - _alternative "files:: _files -g '*core(-.)'" "processes:: _pids -m ${w[1]:t}" + _alternative "files:: _files -g '*core*(-.)'" "processes:: _pids -m ${w[1]:t}" else _description files expl executable _files "$expl[@]" -g '*(-*)' diff --git a/Completion/Unix/Command/_git b/Completion/Unix/Command/_git index b8edc109e..0d705a9da 100644 --- a/Completion/Unix/Command/_git +++ b/Completion/Unix/Command/_git @@ -132,7 +132,7 @@ _git-archive () { declare -a backend_args - if (( words[(I)--format=*] > 0 && words[(I)--format=*] < CURRENT )); then + if (( words[(b:CURRENT-1:I)--format=*] )); then case ${words[$words[(I)--format=*]]#--format=} in (zip) backend_args=( @@ -442,7 +442,7 @@ _git-checkout () { '(-b -B -t --track --patch --detach)--orphan[create a new orphan branch based at given commit]: :__git_branch_names' \ '--ignore-skip-worktree-bits[ignores patterns and adds back any files in <paths>]' \ '(-q --quiet -f --force -m --merge --conflict --patch)'{-m,--merge}'[3way merge current branch, working tree and new branch]' \ - '(-q --quiet -f --force -m --merge --patch)--conflict[same as --merge, using given merge style]:style:(merge diff3)' \ + '(-q --quiet -f --force -m --merge --patch)--conflict=[same as --merge, using given merge style]:style:(merge diff3)' \ '(-)'{-p,--patch}'[interactively select hunks in diff between given tree-ish and working tree]' \ '(-)--[start file arguments]' \ '*:: :->branch-or-tree-ish-or-file' && ret=0 @@ -456,14 +456,13 @@ _git-checkout () { [[ $line[CURRENT] = -* ]] && return if (( CURRENT == 1 )) && [[ -z $opt_args[(I)--] ]]; then # TODO: Allow A...B - local branch_arg='branches::__git_revisions' \ + local branch_arg='' \ remote_branch_noprefix_arg='remote branches::__git_remote_branch_names_noprefix' \ tree_ish_arg='tree-ishs::__git_tree_ishs' \ file_arg='modified-files::__git_modified_files' if [[ -n ${opt_args[(I)-b|-B|--orphan|--detach]} ]]; then remote_branch_noprefix_arg= - tree_ish_arg= file_arg= elif [[ -n $opt_args[(I)--track] ]]; then branch_arg='remote-branches::__git_remote_branch_names' @@ -471,7 +470,6 @@ _git-checkout () { tree_ish_arg= file_arg= elif [[ -n ${opt_args[(I)--ours|--theirs|-m|--conflict|--patch]} ]]; then - branch_arg= remote_branch_noprefix_arg= fi @@ -924,7 +922,7 @@ _git-grep () { # TODO: Need to implement -<num> as a shorthand for -C<num> _arguments -C -A '-*' \ '(-O --open-files-in-pager --no-index)--cached[search blobs registered in index file instead of working tree]' \ - '(--cached)--no-index[search files in current directory, not just treacked files]' \ + '(--cached)--no-index[search files in current directory, not just tracked files]' \ '(--exclude-standard)--no-exclude-standard[also search in ignored files]' \ '(--no-exclude-standard)--exclude-standard[exclude files standard ignore mechanisms]' \ '--untracked[search in untracked files]' \ @@ -950,7 +948,7 @@ _git-grep () { '(-z --null)'{-z,--null}'[output \0 after filenames]' \ '(-c --count)'{-c,--count}'[show number of matching lines in files]' \ '( --no-color)--color=-[color matches]:: :__git_color_whens' \ - '(--color )---no-color[do not color matches]' \ + '(--color )--no-color[do not color matches]' \ '--break[prefix the line number to matching lines]' \ '--heading[show the filename above the matches]' \ '(-A --after-context)'{-A,--after-context=}'[show <num> trailing lines, and separate groups of matches]: :__git_guard_number lines' \ @@ -1089,33 +1087,36 @@ _git-log () { $revision_options \ '-L+[trace the evolution of a line range or regex within a file]:range' \ '(-)--[start file arguments]' \ - '*:: :->commit-range-or-file' && ret=0 + '1: :->first-commit-ranges-or-files' \ + '*: :->commit-ranges-or-files' && ret=0 case $state in - (commit-range-or-file) - case $CURRENT in - (1) - if [[ -n ${opt_args[(I)--]} ]]; then - __git_cached_files && ret=0 - else - _alternative \ - 'commit-ranges::__git_commit_ranges' \ - 'cached-files::__git_cached_files' && ret=0 - fi - ;; - (*) - # TODO: Write a wrapper function that checks whether we have a - # committish range or comittish and calls __git_tree_files - # appropriately. - if __git_is_committish_range $line[1]; then - __git_tree_files ${PREFIX:-.} $(__git_committish_range_last $line[1]) && ret=0 - elif __git_is_committish $line[1]; then - __git_tree_files ${PREFIX:-.} $line[1] && ret=0 - else - __git_cached_files && ret=0 - fi - ;; - esac + (first-commit-ranges-or-files) + if [[ -n ${opt_args[(I)--]} ]]; then + __git_tree_files ${PREFIX:-.} HEAD && ret=0 + else + _alternative \ + 'commit-ranges::__git_commit_ranges' \ + 'cached-files::__git_tree_files ${PREFIX:-.} HEAD' && ret=0 + fi + ;; + (commit-ranges-or-files) + # Multiple revspecs are permitted. + if [[ -z ${opt_args[(I)--]} ]]; then + __git_commit_ranges "$@" && ret=0 + fi + + # TODO: Write a wrapper function that checks whether we have a + # committish range or comittish and calls __git_tree_files + # appropriately. + if __git_is_committish_range $line[1]; then + __git_tree_files ${PREFIX:-.} $(__git_committish_range_last $line[1]) && ret=0 + elif __git_is_committish $line[1]; then + __git_tree_files ${PREFIX:-.} $line[1] && ret=0 + else + __git_tree_files ${PREFIX:-.} HEAD && ret=0 + fi + ;; esac return ret @@ -1287,7 +1288,7 @@ _git-push () { '(--verify)--no-verify[bybass the pre-push hook]' \ '--recurse-submodules=[submodule handling]:submodule handling:((check\:"refuse pushing of supermodule if submodule commit cannot be found on the remote" on-demand\:"push all changed submodules"))' \ - ':: :__git_any_repositories' \ + ': :__git_any_repositories' \ '*: :__git_ref_specs' && ret=0 case $state in @@ -2925,7 +2926,6 @@ _git-config () { (*) # TODO: Do we need to set up a _requested/_next_label? declare -a action - local expl _description values expl "$parts[2]" eval "action=($parts[4])" "$action[1]" "$expl[@]" "${(@)action[2,-1]}" && ret=0 @@ -4976,8 +4976,8 @@ __git_is_treeish () { (( $+functions[__git_is_committish_range] )) || __git_is_committish_range () { [[ $1 == *..(.|)* ]] || return 1 - local first=$(__git_committish_range_first $1) - local last=$(__git_committish_range_last $1) + local first="$(__git_committish_range_first $1)" + local last="$(__git_committish_range_last $1)" [[ $first != *..* && $last != *..* ]] && \ __git_is_committish $first && \ __git_is_committish $last @@ -5025,7 +5025,16 @@ __git_ignore_line_inside_arguments () { (( $+functions[_git_commands] )) || _git_commands () { - local -a main_porcelain_commands + local -a cmdtypes + cmdtypes=( main_porcelain_commands user_commands + third_party_commands ancillary_manipulator_commands + ancillary_interrogator_commands interaction_commands + plumbing_manipulator_commands plumbing_interrogator_commands + plumbing_sync_commands plumbing_sync_helper_commands + plumbing_internal_helper_commands + ) + local -a $cmdtypes + main_porcelain_commands=( add:'add file contents to index' am:'apply patches from a mailbox' @@ -5064,7 +5073,6 @@ _git_commands () { submodule:'initialize, update, or inspect submodules' tag:'create, list, delete or verify tag object signed with GPG') - local -a ancillary_manipulator_commands ancillary_manipulator_commands=( config:'get and set repository or global options' fast-export:'data exporter' @@ -5079,7 +5087,6 @@ _git_commands () { repack:'pack unpacked objects in a repository' replace:'create, list, delete refs to replace objects') - local -a ancillary_interrogator_commands ancillary_interrogator_commands=( blame:'show what revision and author last modified each line of a file' cherry:'find commits not merged upstream' @@ -5097,7 +5104,6 @@ _git_commands () { verify-tag:'check GPG signature of tags' whatchanged:'show commit-logs and differences they introduce') - local -a interaction_commands interaction_commands=( archimport:'import an Arch repository into git' cvsexportcommit:'export a single commit to a CVS checkout' @@ -5109,7 +5115,6 @@ _git_commands () { send-email:'send collection of patches as emails' svn:'bidirectional operation between a Subversion repository and git') - local -a plumbing_manipulator_commands plumbing_manipulator_commands=( apply:'apply patch to files and/or to index' checkout-index:'copy files from index to working directory' @@ -5129,7 +5134,6 @@ _git_commands () { update-ref:'update object name stored in a reference safely' write-tree:'create tree from the current index') - local -a plumbing_interrogator_commands plumbing_interrogator_commands=( cat-file:'provide content or type information for repository objects' diff-files:'compare files in working tree and index' @@ -5149,7 +5153,6 @@ _git_commands () { var:'show git logical variable' verify-pack:'validate packed git archive files') - local -a plumbing_sync_commands plumbing_sync_commands=( daemon:'run a really simple server for git repositories' fetch-pack:'receive missing objects from another repository' @@ -5157,7 +5160,6 @@ _git_commands () { send-pack:'push objects over git protocol to another repository' update-server-info:'update auxiliary information file to help dumb servers') - local -a plumbing_sync_helper_commands plumbing_sync_helper_commands=( http-fetch:'download from remote git repository via HTTP' http-push:'push objects over HTTP/DAV to another repository' @@ -5167,7 +5169,6 @@ _git_commands () { upload-archive:'send archive back to git-archive' upload-pack:'send objects packed back to git fetch-pack') - local -a plumbing_internal_helper_commands plumbing_internal_helper_commands=( check-attr:'display gitattributes information' check-ignore:'debug gitignore/exclude files' @@ -5180,91 +5181,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 + local -a 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 + local cmdtype len dup sep + local -a allcmds allmatching alts disp expl + + zstyle -s ":completion:${curcontext}:" list-separator sep || sep=-- + for cmdtype in $cmdtypes aliases; do + if [[ $cmdtype = aliases ]]; then + for dup in ${${aliases%:*}:*allcmds}; do + aliases=( ${aliases:#$dup:*} ) + done + fi + local -a ${cmdtype}_m + set -A ${cmdtype}_m ${(P)cmdtype%%:*} + allcmds+=( ${(P)${:-${cmdtype}_m}} ) done - - integer ret=1 - - _tags \ - aliases \ - main-porcelain-commands \ - user-commands \ - third-party-commands \ - ancillary-manipulator-commands \ - ancillary-interrogator-commands \ - interaction-commands \ - plumbing-manipulator-commands \ - plumbing-interrogator-commands \ - plumbing-sync-commands \ - plumbing-sync-helper-commands \ - plumbing-internal-helper-commands - - while _tags; do - - _requested aliases && \ - _describe -t aliases 'alias' unique_aliases && ret=0 - - _requested main-porcelain-commands && \ - _describe -t main-porcelain-commands 'main porcelain command' main_porcelain_commands && ret=0 - - _requested user-commands && \ - _describe -t user-commands 'user command' user_commands && ret=0 - - _requested third-party-commands && \ - _describe -t third-party-commands 'third-party command' third_party_commands && ret=0 - - _requested ancillary-manipulator-commands && \ - _describe -t ancillary-manipulator-commands 'ancillary manipulator command' ancillary_manipulator_commands && ret=0 - - _requested ancillary-interrogator-commands && \ - _describe -t ancillary-interrogator-commands 'ancillary interrogator command' ancillary_interrogator_commands && ret=0 - - _requested interaction-commands && \ - _describe -t interaction-commands 'interaction command' interaction_commands && ret=0 - - _requested plumbing-manipulator-commands && \ - _describe -t plumbing-manipulator-commands 'plumbing manipulator command' plumbing_manipulator_commands && ret=0 - - _requested plumbing-interrogator-commands && \ - _describe -t plumbing-interrogator-commands 'plumbing interrogator command' plumbing_interrogator_commands && ret=0 - - _requested plumbing-sync-commands && \ - _describe -t plumbing-sync-commands 'plumbing sync command' plumbing_sync_commands && ret=0 - - _requested plumbing-sync-helper-commands && \ - _describe -t plumbing-sync-helper-commands 'plumbing sync helper command' plumbing_sync_helper_commands && ret=0 - - _requested plumbing-internal-helper-commands && \ - _describe -t plumbing-internal-helper-commands 'plumbing internal helper command' plumbing_internal_helper_commands && ret=0 - - (( ret )) || break + zstyle -T ":completion:${curcontext}:" verbose && disp=(-ld '${cmdtype}_d') + _description '' expl '' # get applicable matchers + compadd "$expl[@]" -O allmatching -a allcmds + len=${#${(O)allmatching//?/.}[1]} # length of longest match + for cmdtype in aliases $cmdtypes; do + local -a ${cmdtype}_d + (( $#disp )) && set -A ${cmdtype}_d \ + ${${(Pr.COLUMNS-4.)cmdtype/(#s)(#m)[^:]##:/${(r.len.)MATCH[1,-2]} $sep }%% #} + alts+=( "${cmdtype//_/-}:${${cmdtype//_/ }%%(e|)s}:compadd ${(e)disp} -a ${cmdtype}_m" ) done - return ret + _alternative $alts } (( $+functions[__git_aliases] )) || @@ -5789,7 +5740,11 @@ __git_tree_ishs () { __git_objects () { compset -P '*:' if [[ -n $IPREFIX ]]; then - __git_tree_files "$PREFIX" "${IPREFIX%:}" + if compset -P ./ ; then + __git_tree_files "$PREFIX" "${IPREFIX%:./}" + else + __git_tree_files --root-relative "$PREFIX" "${IPREFIX%:}" + fi else _alternative \ 'revisions::__git_revisions' \ @@ -6034,12 +5989,23 @@ __git_changed_files () { 'changed-in-working-tree-files::__git_changed-in-working-tree_files' } +# __git_tree_files [--root-relative] FSPATH TREEISH [TREEISH...] [COMPADD OPTIONS] +# +# Complete [presently: a single level of] repository files under FSPATH. +# FSPATH is interpreted as a directory path within each TREEISH. +# FSPATH is relative to cwd, unless --root-relative is specified, in +# which case it is relative to the repository root. (( $+functions[__git_tree_files] )) || __git_tree_files () { local multi_parts_opts local tree Path integer at_least_one_tree_added local -a tree_files compadd_opts + local -a extra_args + + if [[ $1 == --root-relative ]]; then + extra_args+=(--full-tree) + fi zparseopts -D -E -a compadd_opts V: J: 1 2 n f X: M: P: S: r: R: q F: @@ -6047,7 +6013,7 @@ __git_tree_files () { shift (( at_least_one_tree_added = 0 )) for tree in $*; do - tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree --name-only -z $tree $Path 2>/dev/null)"}) + tree_files+=(${(ps:\0:)"$(_call_program tree-files git ls-tree $extra_args --name-only -z $tree $Path 2>/dev/null)"}) __git_command_successful $pipestatus && (( at_least_one_tree_added = 1 )) done @@ -6271,6 +6237,95 @@ __git_setup_diff_stage_options () { ) } +(( $+functions[__git_format_placeholders] )) || +__git_format_placeholders() { + local sep + local -a disp names placeholders expl + if compset -P 'format:'; then + compset -P '(%[^acgCG]|%?[^%]|[^%])#' + if compset -P '%C'; then + _wanted colors expl color compadd reset red green blue + return + fi + if [[ -prefix %G ]]; then + placeholders=( + 'GG:raw verification message' + 'G?:indicate [G]ood, [B]ad, [U]ntrusted or [N]o signature' + 'GS:name of signer' + 'GK:signing key' + ) + disp=( -l ) + elif [[ -prefix %g ]]; then + placeholders=( + gD:'reflog selector' + gd:'short reflog selector' + gn:'reflog identity' + gs:'reflog subject' + ) + disp=( -l ) + elif [[ $PREFIX = (#b)%([ac]) ]]; then + placeholders=( + n:'name' + N:'name (use .mailmap)' + e:'email' + E:'email (use .mailmap)' + d:'date' + D:'date, RFC2822 style' + r:'date, relative' + t:'date, UNIX timestamp' + i:'date, like ISO 8601' + I:'date, strict ISO 8601' + ) + placeholders=( $match[1]$^placeholders ) + else + placeholders=( + H:commit\ hash + h:'abbreviated commit hash' + T:'tree hash' + t:'abbreviated tree hash' + P:'parent hash' + p:'abbreviated parent hash' + a:'author details' + c:'committer details' + d:'ref name in brackets' + D:'ref name' + e:encoding + s:subject + f:'sanitized subject' + g:reflog + b:body + B:'raw body' + N:notes + G:GPG\ details + C:color + m:mark + n:newline + %:raw\ % + x:'hex code' + w:'switch line wrapping' + ) + fi + names=( ${placeholders%%:*} ) + if zstyle -T ":completion:${curcontext}:" verbose; then + zstyle -s ":completion:${curcontext}:" list-separator sep || sep=-- + zformat -a placeholders " $sep " $placeholders + disp+=(-d placeholders) + else + disp=() + fi + _wanted placeholders expl placeholder \ + compadd -p % -S '' "$disp[@]" "$@" - "$names[@]" + else + _describe -t formats format '( oneline:"commit-ids and subject of messages" + short:"few headers and only subject of messages" + medium:"most parts of messages" + full:"all parts of commit messages" + fuller:"like full and includes dates" + email:"use email headers like From and Subject" + raw:"the raw commits" )' -- '( format:"specify own format" )' -S ':' + fi +} + (( $+functions[__git_setup_revision_options] )) || __git_setup_revision_options () { local -a diff_options @@ -6278,16 +6333,7 @@ __git_setup_revision_options () { revision_options=( $diff_options - # TODO: format pretty print format is a lot more advanced than this. - # TODO: You can't actually specify --format without a format. - '(-v --header)'{--pretty=-,--format=-}'[pretty print commit messages]::format:((oneline\:"commit-ids and subject of messages" - short\:"few headers and only subject of messages" - medium\:"most parts of messages" - full\:"all parts of commit messages" - fuller\:"like full and includes dates" - email\:"use email headers like From and Subject" - raw\:"the raw commits" - format\:"specify own format"))' + '(-v --header)'{--pretty=-,--format=-}'[pretty print commit messages]::format:__git_format_placeholders' '(--abbrev-commit --no-abbrev-commit)--abbrev-commit[show only partial prefixes of commit object names]' '(--abbrev-commit --no-abbrev-commit)--no-abbrev-commit[show the full 40-byte hexadecimal commit object name]' '(--abbrev --no-abbrev)--abbrev=[set minimum SHA1 display-length (for use with --abbrev-commit)]: :__git_guard_number length' @@ -6329,8 +6375,8 @@ __git_setup_revision_options () { '*--not[reverses meaning of ^ prefix for revisions that follow]' '--all[show all commits from refs]' '--branches=-[show all commits from refs/heads]::pattern' - '--tags=[-show all commits from refs/tags]::pattern' - '--remotes=[-show all commits from refs/remotes]::pattern' + '--tags=-[show all commits from refs/tags]::pattern' + '--remotes=-[show all commits from refs/remotes]::pattern' '--glob=[show all commits from refs matching glob]:pattern' '--exclude=[do not include refs matching glob]:pattern' '--exclude=[do not include refs matching glob]:pattern' diff --git a/Completion/Unix/Command/_gzip b/Completion/Unix/Command/_gzip index 927d31d45..f9fd17819 100644 --- a/Completion/Unix/Command/_gzip +++ b/Completion/Unix/Command/_gzip @@ -1,37 +1,57 @@ -#compdef gzip gunzip gzcat=gunzip -redirect-,<,gunzip=gunzip -redirect-,>,gzip=gunzip -redirect-,<,gzip=gzip -value-,GZIP,-default- +#compdef gzip gunzip gzcat=gunzip pigz unpigz -redirect-,<,gunzip=gunzip -redirect-,>,gzip=gunzip -redirect-,<,gzip=gzip -value-,GZIP,-default- local decompress files expl curcontext="$curcontext" state line ret=1 +local -a pigz typeset -A opt_args +local excl="--decompress --uncompress -1 -2 -3 -4 -5 -6 -7 -8 -9 -11 --best" files=( '*:files:->files' ) case "$service" in +unpigz|pigz) + pigz=( + '(-K --zip)'{-K,--zip}'[compress to PKWare zip format]' + '(-b --blocksize)'{-b+,--blocksize}'[set compression block size]:size (KiB)' + '(-p --processes)'{-p,--processes}'[specify number of processes to use]' + '(-z --zlib)'{-z,--zlib}'[compress to zlib (.zz) format]' + '(-T --no-time)'{-T,--no-time}"[don't store/restore modification time in/from header]" + ) +;| +pigz) + pigz+=( + '(-i --independent)'{-i,--independent}'[compress blocks independently to allow for damage recovery]' + "($excl)-11" + '(--rsyncable)-R[make rsync-friendly archive]' + "($excl)"{-F,--first}'[do iterations first, before block split]' + "($excl)"{-I+,--iterations}'[specify number of iterations for optimization]:iterations [15]' + "($excl)"{-M+,--maxsplits}'[specify maximum number of split blocks]:split blocks [15]' + "($excl)"{-O,--oneblock}"[don't split into smaller blocks]" + ) +;| *GZIP*) compset -q words=( fake "$words[@]" ) (( CURRENT++ )) files=() ;& -gunzip|zcat) +gunzip|zcat|unpigz) decompress=yes ;& -gzip) +gzip|pigz) _arguments -C -s -S \ '(--to-stdout --stdout)-c[write on standard output]' \ '(-c --stdout)--to-stdout[write on standard output]' \ '(-c --to-stdout)--stdout[write on standard output]' \ - '(--decompress --uncompress)-d[decompress]' \ - '(-d --uncompress)--decompress[decompress]' \ - '(-d --decompress)--uncompress[decompress]' \ + "($excl)"{-d,--decompress,--uncompress}'[decompress]' \ '(--force)-f[force overwrite]' \ '(-f)--force[force overwrite]' \ - '(--help)-h[display help message]' \ - '(-h)--help[display help message]' \ + '(- *)'{-h,--help}'[display help message]' \ + "(--keep)-k[don't delete input files]" \ + "(-k)--keep[don't delete input files]" \ '(--list)-l[list compressed file contents]' \ '(-l)--list[list compressed file contents]' \ - '(--license)-L[display software license]' \ - '(-L)--license[display software license]' \ - '(--no-name)-n[do not save or restore the original name and time stamp]' \ - '(-n)--no-name[do not save or restore the original name and time stamp]' \ + '(- *)'{-L,--license}'[display software license]' \ + "(--no-name)-n[don't save or restore the original name and time stamp]" \ + "(-n)--no-name[don't save or restore the original name and time stamp]" \ '(--name)-N[save or restore the original name and time stamp]' \ '(-N)--name[save or restore the original name and time stamp]' \ '(--quiet --silent)-q[suppress all warnings]' \ @@ -39,27 +59,16 @@ gzip) '(-q --quiet)--silent[suppress all warnings]' \ '(--recursive)-r[operate recursively on directories]' \ '(-r)--recursive[operate recursively on directories]' \ - '--rsyncable[make rsync-friendly archive]' \ + '(-R)--rsyncable[make rsync-friendly archive]' \ '(--suffix)-S+[specify suffix for compressed files]:suffix:' \ '(-S)--suffix=[specify suffix for compressed files]:suffix:' \ '(--test)-t[test compressed file integrity]' \ '(-t)--test[test compressed file integrity]' \ '(--verbose)-v[verbose mode]' \ '(-v)--verbose[verbose mode]' \ - '(--version)-V[display version number]' \ - '(-V)--version[display version number]' \ - '( -1 -2 -3 -4 -5 -6 -7 -8 -9 --best)--fast' \ - '(--fast -2 -3 -4 -5 -6 -7 -8 -9 --best)-1' \ - '(--fast -1 -3 -4 -5 -6 -7 -8 -9 --best)-2' \ - '(--fast -1 -2 -4 -5 -6 -7 -8 -9 --best)-3' \ - '(--fast -1 -2 -3 -5 -6 -7 -8 -9 --best)-4' \ - '(--fast -1 -2 -3 -4 -6 -7 -8 -9 --best)-5' \ - '(--fast -1 -2 -3 -4 -5 -7 -8 -9 --best)-6' \ - '(--fast -1 -2 -3 -4 -5 -6 -8 -9 --best)-7' \ - '(--fast -1 -2 -3 -4 -5 -6 -7 -9 --best)-8' \ - '(--fast -1 -2 -3 -4 -5 -6 -7 -8 --best)-9' \ - '(--fast -1 -2 -3 -4 -5 -6 -7 -8 -9 )--best' \ - "$files[@]" && ret=0 + '(- *)'{-V,--version}'[display version number]' \ + "($excl)"-{-fast,1,2,3,4,5,6,7,8,9,-best} \ + "$pigz[@]" "$files[@]" && ret=0 ;; esac diff --git a/Completion/Unix/Command/_ifconfig b/Completion/Unix/Command/_ifconfig index 49b018841..0c81bce10 100644 --- a/Completion/Unix/Command/_ifconfig +++ b/Completion/Unix/Command/_ifconfig @@ -65,7 +65,7 @@ esac _arguments -C "$args[@]" \ '-a[apply to all interfaces]' \ - '1:network interface:_net_interfaces' \ + '1:network interface:_net_interfaces -r ": \t\n\-"' \ '::address family:(atalk ether inet inet6 ax25 ddp ipx netrom)' \ '*:option:->options' && ret=0 diff --git a/Completion/Unix/Command/_imagemagick b/Completion/Unix/Command/_imagemagick index 115cb01e4..1fc6089c8 100644 --- a/Completion/Unix/Command/_imagemagick +++ b/Completion/Unix/Command/_imagemagick @@ -1,6 +1,7 @@ #compdef animate composite combine convert display identify import mogrify montage xtp -local state line expl formats curcontext="$curcontext" +local state line expl curcontext="$curcontext" +local -a formats typeset -A opt_args # Things that could be improved: @@ -11,10 +12,10 @@ typeset -A opt_args # # and certainly many other things... -formats=jpg:jpeg:jp2:j2k:jpc:jpx:jpf:tiff:miff:ras:bmp:cgm:dcx:ps:eps:fig:fits:fpx:gif:mpeg:pbm:pgm:ppm:pcd:pcl:pdf:pcx:png:rad:rgb:rgba:rle:sgi:html:shtml:tga:ttf:uil:xcf:xwd:xbm:xpm:yuv +formats=(jpg jpeg jp2 j2k jpc jpx jpf tiff miff ras bmp cgm dcx ps eps fig fits fpx gif mpeg pbm pgm ppm pcd pcl pdf pcx png rad rgb rgba rle sgi html shtml tga ttf uil xcf xwd xbm xpm yuv) if (( $# )); then - _files "$@" -g "*.(#i)(${~formats//:/|})(-.)" + _files "$@" -g "*.(#i)(${(j:|:)formats})(-.)" return fi @@ -444,7 +445,7 @@ case "$service" in '*-filter:filter type for resizing:(Point Box Triangle Hermite Hanning Hamming Blackman Gaussian Quadratic Cubic Catrom Mitchell Lanczos Bessel Sinc)' \ '*-flip[vertical mirror image]' \ '*-flop[horizontal mirror image]' \ - "*-format:output file format:(${formats//:/ })" \ + "*-format:output file format:($formats)" \ '*-font:annotation font:_x_font' \ '*-frame:border dimensions (<width>x<height>+<out>+<in>)' \ '*-fuzz:maximum distance for equal colors' \ diff --git a/Completion/Unix/Command/_java b/Completion/Unix/Command/_java index 7b1dce18f..2aef15a25 100644 --- a/Completion/Unix/Command/_java +++ b/Completion/Unix/Command/_java @@ -7,45 +7,76 @@ typeset -A opt_args tmpassoc jdb_args=() case "$service" in +javac|jar) + if compset -P @; then + _wanted files expl 'option file' _files + return + fi + ;| # continue javac) _arguments -C \ '-g-[generate debugging information]:debug:->debug' \ + '-A-[specify option to annotation processors]:option' \ + '-implicit\:-[control generation of class files for implicitly loaded sources]:implicit:(class none)' \ '-nowarn[generate no warnings]' \ '-verbose[output messages about what the compiler is doing]' \ '-deprecation[output source locations where deprecated APIs are used]' \ - '-classpath[specify where to find user class files]:class path:->classpath' \ + '(-cp -classpath)'{-cp,-classpath}'[specify where to find user class files]:class path:->classpath' \ '-sourcepath[specify where to find input source files]:source path:->sourcepath' \ '-bootclasspath[override location of bootstrap class files]:bootstrap class path:->bootstrapclasspath' \ '-extdirs[override location of installed extensions]:extensions directories:->extdirs' \ '-d[specify where to place generated class files]:directory:_files -/' \ '-encoding[specify character encoding used by source files]:encoding:->encoding' \ - '-source[provide source compatibility with specified release]:release:(1.{2..5})' \ + '-proc\:-[control annotation processing]:annotation processing:(none only)' \ + '-processor[specify annotation processors to run]:class:_files' \ + '-processorpath[specify where to find annotation processors]:directory:_directories' \ + '-s[specify directory for generated source files]:directory:_directories' \ + '-source[provide source compatibility with specified release]:release:(1.{2..8} {5..8})' \ '-target[specify VM version]:release:(1.{1..5})' \ - '-help[print a synopsis of standard options]' \ + '(-)-help[print a synopsis of standard options]' \ + '(-)-version[print version information]' \ + '(-)-X[display information about non-standard options]' \ '*:java source file:_files -g \*.java\(-.\)' && return 0 ;; jdb) jdb_args=( '-host[specify host to connect to]:host:_hosts' - '-password[specify password]:password:' + '-password[specify password]:password' + '-attach[attach to running VM]:address' + '-listen[wait for VM to connect]:address' + '-listenany[wait for VM to connect at any available address]' + '-launch[launch VM immediately]' + '-listconnectors[list the connectors available in this VM]' + '-connect[connect to target VM]:connector' + -dbgtrace -tclient -tserver + '-J-[java runtime option]:option' ) ;& java) _arguments -C \ "$jdb_args[@]" \ + -client -server -d32 -d64 \ + '-agentlib\:-:agent library' \ + '-agentpath\:-:path:_directories' \ + '-javaagent\:-:path:_directories' \ '(-cp -classpath)'{-cp,-classpath}'[specify path for user class files]:class path:->classpath' \ '-D-[specify a property]:property:->property' \ + \*{-enableassertions,-ea}-::class \ + \*{-disableassertions,-da}-::class \ + '(-enablesystemassertions,-esa,-disablesystemassertions,-dsa)'{-enablesystemassertions,-esa,-disablesystemassertions,-dsa} \ '(-verbose:class)-verbose[print class information]' \ '(-verbose)-verbose\:class[print class information]' \ '-verbose\:gc[print gc information]' \ '-verbose\:jni[print JNI information]' \ - '-version[print version]' \ - '-help[print help message]' \ - '(- 1)-jar[specify a program capsulated as jar]:jar:_files -g \*.jar\(-.\)' \ + '(- 1)-version[print version]' \ + '-showversion[print version and contrinue]' \ + '(- 1)-'{\?,help}'[print help message]' \ + '(- 1)-X-[non-standard java option]:option' \ + '(- 1)-jar[specify a program encapsulated as jar]:jar:_files -g \*.jar\(-.\)' \ '(-):class:_java_class -m main ${(kv)opt_args[(i)(-classpath|-cp)]}' \ - '*::args: _normal' \ + '*::args:= _normal' \ && return 0 ;; @@ -111,16 +142,20 @@ jar) '(c t x )u[update archive]' \ 'f[specify archive file]' \ 'v[verbose mode]' \ - 'm[specify manifest file]' \ + '(e)m[specify manifest file]' \ + '(m)e[specify class of for application entry point]' \ '0[store only without using ZIP compression]' \ - 'M[do not create manifest file]' && return + 'M[do not create manifest file]' \ + 'i[generate index information for specified jar files]' && return else jar_cmd="${words[2]#-}" tmpassoc=( m ':manifest file:_files' + e ':main class' f ':archive file:_files -g "*.([ejw]ar|zip)(-.)"' ) - _arguments -C \ + _arguments '*-C[directory of class file]:directory:_directories' \ + '-J-[java runtime option]:option' \ "${jar_cmd/[^-]*/:dummy:}" \ ${${(s::)jar_cmd}/(#b)(?)/$tmpassoc[$match[1]]} \ '*:file:->jararg' && return 0 @@ -140,6 +175,7 @@ javah|javah_g) '-bootclasspath[specify path for bootstrap class files]:bootstrap class path:->bootstrapclasspath' \ '-old[generate old JDK1.0-style header files]' \ '-force[force output]' \ + '-J-[java runtime option]:option' \ '*:class:_java_class -m main ${(kv)opt_args[(i)-classpath]}' && return 0 ;; @@ -558,20 +594,14 @@ docsrc) ;; jararg) - if [[ -prefix - ]]; then - tmp=('-C:chdir') - _describe -o 'option' tmp -- && return - elif [[ "$words[CURRENT - 2]" == -C ]]; then + if [[ "$words[CURRENT - 2]" == -C ]]; then _wanted file expl 'input file' _files -W "($words[CURRENT - 1])" && return - elif [[ "$words[CURRENT - 1]" == -C ]]; then - _wanted directories expl 'chdir to' _files -/ && return elif [[ $words[2] = *x* ]]; then jf="$words[3]" if [[ $jf != $_jar_cache_name && -f $jf ]]; then _jar_cache_list=("${(@f)$($words[1] tf $jf)}") _jar_cache_name=$jf fi - _wanted files expl 'file from archive' _multi_parts / _jar_cache_list && return else _wanted files expl 'input file' _files && return diff --git a/Completion/Unix/Command/_kvno b/Completion/Unix/Command/_kvno index 285aab3c8..782d9e6fc 100644 --- a/Completion/Unix/Command/_kvno +++ b/Completion/Unix/Command/_kvno @@ -11,8 +11,7 @@ _arguments -C \ ':principal:->principal' && ret=0 if [[ $state = principal ]]; then - if [[ -prefix host/ ]]; then - compset -P host/ + if compset -P host/; then _hosts && ret=0 else _alternative \ diff --git a/Completion/Unix/Command/_last b/Completion/Unix/Command/_last index 706d82f26..f198e0fff 100644 --- a/Completion/Unix/Command/_last +++ b/Completion/Unix/Command/_last @@ -9,7 +9,7 @@ for pattern arg in \ '((free|net|open)bsd*|darwin*|dragonfly*|linux-gnu)' '-h[limit sessions by hostname]:host:_hosts' \ '((free|open)bsd*|linux-gnu)' '-s[report duration in seconds]' \ '(freebsd*|openbsd*)' '-d[limit sessions to those active at snapshot time]:time ([[CC]YY][MMDD]hhmm[.SS])' \ - '((net|free|open)bsd*|darwin*|dragonfly*)' '-t[limit sessions by tty]:tty:compadd -a ttys' \ + '((net|free|open)bsd*|darwin*|dragonfly*)' '-t[limit sessions by tty]:tty:_ttys -D' \ 'openbsd*' '-c[calculate total time]' \ '^darwin*' '-f[specify account file]:file:_files' \ '(solaris*|linux-gnu|freebsd*|openbsd*)' '-n[specify number of lines to show]:number' \ @@ -45,7 +45,7 @@ case $OSTYPE in esac if [[ $OSTYPE = (linux-gnu|solaris*) ]]; then - args+=( '*:arg: _alternative "users:user:_users" "ttys:tty:compadd -a ttys"' ) + args+=( '*:arg: _alternative "users:user:_users" "ttys:tty:_ttys -d" "ttys:tty:(reboot)"' ) else args+=( '*:user:_users' ) fi diff --git a/Completion/Unix/Command/_make b/Completion/Unix/Command/_make index c14a34c58..48befa749 100644 --- a/Completion/Unix/Command/_make +++ b/Completion/Unix/Command/_make @@ -4,58 +4,68 @@ # are used in those targets and their dependencies. _make-expandVars() { - local open close var val front ret tmp=$1 + local open close var val front='' rest=$1 - front=${tmp%%\$*} - case $tmp in - (\(*) # Variable of the form $(foobar) - open='(' - close=')' - ;; - - ({*) # ${foobar} - open='{' - close='}' - ;; - - ([[:alpha:]]*) # $foobar. This is exactly $(f)oobar. - open='' - close='' - var=${(s::)var[1]} - ;; - - (\$*) # Escaped $. - print -- "${front}\$$(_make-expandVars ${tmp#\$})" - return - ;; + while [[ $rest == (#b)[^$]#($)* ]]; do + front=$front${rest[1,$mbegin[1]-1]} + rest=${rest[$mbegin[1],-1]} - (*) # Nothing left to substitute. - print -- $tmp - return - ;; - esac - - if [[ -n $open ]] - then - var=${tmp#$open} - var=${var%%$close*} - fi + case $rest[2] in + ($) # '$$'. may not appear in target and variable's value + front=$front\$\$ + rest=${rest[3,-1]} + continue + ;; + (\() # Variable of the form $(foobar) + open='(' + close=')' + ;; + ({) # ${foobar} + open='{' + close='}' + ;; + ([[:alpha:]]) # $foobar. This is exactly $(f)oobar. + open='' + close='' + var=$rest[2] + ;; + (*) # bad parameter name + print -- $front$rest + return 1 + ;; + esac - case $var in - ([[:alnum:]_]#) - val=${VARIABLES[$var]} - ret=${ret//\$$open$var$close/$val} - ;; + if [[ -n $open ]]; then + if [[ $rest == \$$open(#b)([[:alnum:]_]##)(#B)$close* ]]; then + var=$match + else # unmatched () or {}, or bad parameter name + print -- $front$rest + return 1 + fi + fi - (*) - # Improper variable name. No replacement. - # I'm not sure if this is desired behavior. - front+="\$$open$var$close" - ret=${ret/\$$open$var$close/} - ;; - esac + val='' + if [[ -n ${VAR_ARGS[(i)$var]} ]]; then + val=${VAR_ARGS[$var]} + else + if [[ -n $opt_args[(I)(-e|--environment-overrides)] ]]; then + if [[ $parameters[$var] == scalar-export* ]]; then + val=${(P)var} + elif [[ -n ${VARIABLES[(i)$var]} ]]; then + val=${VARIABLES[$var]} + fi + else + if [[ -n ${VARIABLES[(i)$var]} ]]; then + val=${VARIABLES[$var]} + elif [[ $parameters[$var] == scalar-export* ]]; then + val=${(P)var} + fi + fi + fi + rest=${rest//\$$open$var$close/$val} + done - print -- "${front}$(_make-expandVars ${ret})" + print -- ${front}${rest} } _make-parseMakefile () { @@ -84,16 +94,9 @@ _make-parseMakefile () { # TARGET: dependencies # TARGET1 TARGET2 TARGET3: dependencies - ([[:alnum:]][^$TAB:=]#:[^=]*) - input=$(_make-expandVars $input) - target=${input%%:*} - dep=${input#*:} - dep=${(z)dep} - dep="$dep" - for tmp in ${(z)target} - do - TARGETS[$tmp]=$dep - done + ([[*?[:alnum:]$][^$TAB:=%]#:[^=]*) + target=$(_make-expandVars ${input%%:*}) + TARGETS+=( ${(z)target} ) ;; # Include another makefile @@ -150,9 +153,18 @@ _make() { local prev="$words[CURRENT-1]" file expl tmp is_gnu dir incl match local context state state_descr line local -a option_specs - local -A TARGETS VARIABLES opt_args + local -A VARIABLES VAR_ARGS opt_args + local -aU TARGETS keys local ret=1 + # VAR=VAL on the current command line + for tmp in $words; do + if [[ $tmp == (#b)([[:alnum:]_]##)=(*) ]]; then + VAR_ARGS[${tmp[$mbegin[1],$mend[1]]}]=${(e)tmp[$mbegin[2],$mend[2]]} + fi + done + keys=( ${(k)VAR_ARGS} ) # to be used in 'compadd -F keys' + _pick_variant -r is_gnu gnu=GNU unix -v -f if [[ $is_gnu == gnu ]] @@ -275,9 +287,9 @@ _make() { while _tags do _requested targets expl 'make targets' \ - compadd -- ${(k)TARGETS} && ret=0 + compadd -Q -- $TARGETS && ret=0 _requested variables expl 'make variables' \ - compadd -S '=' -- ${(k)VARIABLES} && ret=0 + compadd -S '=' -F keys -- ${(k)VARIABLES} && ret=0 done fi esac diff --git a/Completion/Unix/Command/_mh b/Completion/Unix/Command/_mh index 48177982e..3eddd41a6 100644 --- a/Completion/Unix/Command/_mh +++ b/Completion/Unix/Command/_mh @@ -1,4 +1,4 @@ -#compdef ali anno burst comp dist flist flists folder folders forw inc mark mhlist mhmail mhn mhparam mhpath mhshow mhstore msgchk next packf pick prev refile repl rmf rmm scan show sortm whom +#compdef ali anno burst comp dist flist flists fmttest folder folders forw fnext fprev inc mark mhfixmsg mhlist mhmail mhn mhparam mhpath mhshow mhstore msgchk new next packf pick prev refile repl rmf rmm scan show sortm whom if [[ -z $commands[mhpath] ]]; then _message "MH commands are not available" @@ -73,7 +73,9 @@ elif [[ $service = mhparam ]]; then elif [[ $service = ali ]]; then _email_addresses -n MH elif compset -P '*:'; then - _message -e number 'number of messages' + _alternative \ + 'sequences:sub-sequence:(first last cur prev next)' + 'number: : _message -e number "number of messages"' else # Generate sequences. local foldnam folddir f sequences mhneg ret=1 @@ -95,6 +97,7 @@ else sequences=( ${${(f)"$(mark $foldnam 2>/dev/null)"}%%:*} ) mhneg="$(mhparam Sequence-Negation)" && sequences=( {,$mhneg}$^sequences ) sequences+=( all first last prev next ) + [[ $service = mhpath ]] && sequences+=( new ) _tags sequences while _tags; do while _next_label sequences expl sequence; do diff --git a/Completion/Unix/Command/_ncftp b/Completion/Unix/Command/_ncftp index 93de404aa..763a61344 100644 --- a/Completion/Unix/Command/_ncftp +++ b/Completion/Unix/Command/_ncftp @@ -1,6 +1,12 @@ #compdef ncftp lftp -local expl bookmarks=$HOME/.$service/bookmarks +local expl bookmarks XDG_DATA_HOME=${XDG_DATA_HOME:-$HOME/.local/share} + +if [[ $service = lftp ]]; then + bookmarks=$XDG_DATA_HOME/$service/bookmarks +else + bookmarks=$HOME/.$service/bookmarks +fi if [[ -f $bookmarks ]]; then bookmarks=(${"${(f)$(<$bookmarks)}"%%[[:space:],]*}) diff --git a/Completion/Unix/Command/_patchutils b/Completion/Unix/Command/_patchutils new file mode 100644 index 000000000..323c0a730 --- /dev/null +++ b/Completion/Unix/Command/_patchutils @@ -0,0 +1,106 @@ +#compdef combinediff interdiff filterdiff flipdiff grepdiff lsdiff splitdiff unwrapdiff + +local args +args=( + '(-)--help[display help information]' + '(-)--version[display version information]' +) + +case $service in + (inter|combine|filter|flip|ls|grep)diff) + args+=( + '(-p --strip-match=)'{-p,--strip-match=}'[specify number of path prefix components to strip]:number of path prefix components to strip' + '(-z --decompress)'{-z,--decompress}'[decompress .gz and .bz2 files]' + ) + ;| + interdiff|combinediff|flipdiff) + args+=( + '(-q --quiet)'{-q,--quiet}'[quieter output]' + '(-U --unified)'{-U,--unified=}'[specify lines of context to include]:lines of context' + \*{-d,--drop-context=}"[don't include context on files matching pattern]:pattern:_files" + '(-w --ignore-all-space)'{-w,--ignore-all-space}'[ignore all whitespace changes in patches]' + '(-B --ignore-blank-lines)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' + '(-i --ignore-case)'{-i,--ignore-case}'[ignore case differences]' + '(-b --ignore-space-change)'{-b,--ignore-space-change}'[ignore changes in the amount of whitespace]' + '!(--in-place)--interpolate' '!-h' + '!(--no-revert-omitted --in-place)--combinediff' + '!(--no-revert-omitted)--flip' + '1:diff 1:_files' '2:diff 2:_files' + ) + ;| + interdiff) + args+=( + "--no-revert-omitted[don't revert files changed in only the first patch]" + ) + ;; + flipdiff) args+=( '--in-place[write output to original input files]' ) ;; + filterdiff|grepdiff|lsdiff) + args+=( + '(-i --include)'{-i,--include}'[include only files matching pattern]:pattern:_files' + '(-x --exclude)'{-x,--exclude}'[exclude files matching pattern]:pattern:_files' + '(-# --hunks)'{-#+,--hunks=}'[only list hunks within specified range]:range' + '--lines=[only list hunks containing lines within specified range]:range' + '(-F --files)'{-F+,--files=}'[only list files within specified range]:range' + '--strip=[remove specified number of pathname components before displaying]:components' + '--addprefix=[insert specified path prefix before displaying path names]:prefix:_directories' + ) + ;| + grepdiff|lsdiff) + args+=( + '(-n --line-number)'{-n,--line-number}'[show line number at which each patch begins]' + '(-N --number-files)'{-N,--number-files}'[show file number before each filename]' + '(-s --status)'{-s,--status}'[mark added, modified and removed files]' + ) + ;| + lsdiff) + args+=( + '(-E --empty-files-as-removed)'{-E,--empty-files-as-removed}'[treat empty files as absent]' + \*{-v,--verbose}'[verbose operation]' + '(-H --with-filename -h --no-filename)'{-H,--with-filename}'[print the name of the patch file containing each patch]' + '!--filter' '!--grep' + '*:diff file:_files' + ) + ;; + grepdiff|filterdiff) + args+=( + '(-I --include-from-file)'{-I+,--include-from-file=}'[include only files matching pattern listed in specified file]:file:_files' + '--annotate[annotate each hunk with the filename and hunk number]' + '--format=[use specified output format]:format:(unified context)' + '--addnewprefix=[insert specified path prefix before new file path names]:prefix:_directories' + '--addoldprefix=[insert specified path prefix before original file path names]:prefix:_directories' + '--as-numbered-lines=[display lines of selected hunks]:line numbers:(before after)' + "--remove-timestamps[don't include timestamps in output]" + ) + ;; + filterdiff) + args+=( + '(-X --exclude-from-file)'{-X+,--exclude-from-file=}'[exclude files matching any pattern listed in specified file]:file:_files' + '(-v --verbose --clean)'{-v,--verbose}'[always show non-diff lines in output]' + '(-v --verbose)--clean[always remove all non-diff lines from output]' + ) + ;; + grepdiff) + args+=( + '(-E --extended-regexp)'{-E,--extended-regexp}'[use extended regular expressions]' + '(-H --with-filename -h --no-filename)'{-h,--no-filename}"[don't print the name of the patch file containing each patch]" + '(-f --file)'{-f+,--file=}'[read regular expressions from file]:file:_files' + '--output-matching=[display the matching hunk- or file-level diffs]:level:(hunk file)' + ) + ;; + splitdiff) + args+=( + '-a[split every single file level patch]' + '-d[create file names such as a_b.c.patch for a patch that modifies a/b.c]' + '-D[write output files into specified directory]:_directories' + '-p[specify number of path prefix components to strip]:number of path prefix components to strip' + "-E[don't use .patch filename extension when writing output files]" + '1:diff file:_files' + ) + ;; + unwrapdiff) + args+=( '-v[verbose operation]' '*:diff file:_files' ) + ;; +esac + +_arguments -s $args + diff --git a/Completion/Unix/Command/_pgrep b/Completion/Unix/Command/_pgrep index d3dcd1812..0b7d23d4d 100644 --- a/Completion/Unix/Command/_pgrep +++ b/Completion/Unix/Command/_pgrep @@ -13,7 +13,7 @@ arguments=('-P[parent process id]:parent process id:->ppid' '-M[extract the name list from the specified core]:files:_files' '-N[extract the name list from the specified system]:files:_files' '-s[match only session id]:session id:->sid' - '-t[match only controlled by terminal]:terminal device:->tty' + '-t[match only controlled by terminal]:terminal device:_sequence _ttys -d' '-T[match only in processes specified routing table in rtable]' '-u[match only effective user id]:user:_users' '-U[match only real user id]:user:_users' @@ -69,12 +69,6 @@ arguments=( ${(M)arguments:#(|\*)(|\(*\))-[$optchars]*} _arguments -C -s -w $arguments && ret=0 case $state in - (tty) - local -a ttys - ttys=( /dev/tty*(N) /dev/pts/*(N) ) - _sequence -s , _wanted tty expl 'terminal device' compadd - ${ttys#/dev/} - ;; - (sid) if [[ $OSTYPE == openbsd* ]]; then break diff --git a/Completion/Unix/Command/_ps b/Completion/Unix/Command/_ps index e557b27b9..6f67f7933 100644 --- a/Completion/Unix/Command/_ps +++ b/Completion/Unix/Command/_ps @@ -31,7 +31,7 @@ args=( '*-G+[select processes by real group]:group:_sequence -s , _groups' '*-g+[select processes by effective group or session]:group:_sequence -s , _groups' '*-s+[select processes by session leaders]:session leader:_sequence -s , _pids' - '*-t+[select processes by attached terminal]:tty:_sequence -s , compadd - /dev/pts/<->(N\:s/\\/dev\\//) /dev/tty*(N\:t)' + '*-t+[select processes by attached terminal]:tty:_sequence -s , _ttys -D' '*-u+[select processes by effective user]:user:_sequence -s , _users' '*-U+[select processes by real user]:user:_sequence -s , _users' '-o+[specify output format]:property:_sequence -s , _ps_props -' @@ -163,8 +163,7 @@ if (( CURRENT > 1 )) && [[ $OSTYPE != solaris* || ( $OSTYPE = linux-gnu && $word *J) _sequence _jails -0 && return ;; *[MNW]) _files && return ;; *t) - _wanted -C option-t-1 ttys expl tty _sequence -s , \ - compadd - /dev/pts/<->(N\:s/\\/dev\\//) /dev/tty*(N\:t) && return + _wanted -C option-t-1 ttys expl tty _sequence -s , _ttys -D && return ;; *p) _wanted -C option-p-1 processes expl 'process ID' _sequence -s , _pids && return;; *U) _wanted -C option-U-1 users expl user _sequence -s , _users && return ;; diff --git a/Completion/Unix/Command/_rm b/Completion/Unix/Command/_rm index 4728ad464..4d0dbdb3f 100644 --- a/Completion/Unix/Command/_rm +++ b/Completion/Unix/Command/_rm @@ -40,7 +40,7 @@ fi local curcontext=$curcontext state line ret=1 declare -A opt_args -_arguments -C $opts \ +_arguments -C -s $opts \ $args && ret=0 case $state in diff --git a/Completion/Unix/Command/_sort b/Completion/Unix/Command/_sort index 2e7f0a01a..1ad57f442 100644 --- a/Completion/Unix/Command/_sort +++ b/Completion/Unix/Command/_sort @@ -55,7 +55,7 @@ case $variant in netbsd*|dragonfly*) args+=( "${ordering}-l[sort by string length of field]" - "(-s)-S[don't use stable sort" + "(-s)-S[don't use stable sort]" ) ;| openbsd*) diff --git a/Completion/Unix/Command/_ssh b/Completion/Unix/Command/_ssh index 2be5672da..a66702a65 100644 --- a/Completion/Unix/Command/_ssh +++ b/Completion/Unix/Command/_ssh @@ -1,6 +1,6 @@ #compdef ssh slogin=ssh scp ssh-add ssh-agent ssh-keygen sftp ssh-copy-id -# Completions currently based on OpenSSH 6.0 (released on 2012-04-22). +# Completions currently based on OpenSSH 7.0 (released on 2015-08-11). # # TODO: update ssh-keygen (not based on 5.9) # TODO: sshd, ssh-keyscan, ssh-keysign @@ -39,8 +39,10 @@ _ssh () { '(-P)-b+[specify interface to transmit on]:bind address:_bind_addresses' \ '-D+[specify a dynamic port forwarding]:dynamic port forwarding:->dynforward' \ '-e+[set escape character]:escape character (or `none'\''):' \ + '-E[append log output to file instead of stderr]:_files' \ '(-n)-f[go to background]' \ '-g[allow remote hosts to connect to local forwarded ports]' \ + '-G[output configuration and exit]' \ '-I+[specify smartcard device]:device:_files' \ '-K[enable GSSAPI-based authentication and forwarding]' \ '-k[disable forwarding of GSSAPI credentials]' \ @@ -56,11 +58,12 @@ _ssh () { '(-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' \ + '-Q[query parameters]:parameter type:((cipher\:"supported symmetric ciphers" cipher-auth\:"supported symmetric ciphers that support authenticated encryption" mac\:"supported message integrity codes" kex\:"key exchange algorithms" key\:"key types" protocol-version\:"supported SSH protocol versions"))' \ '(-1)-s[invoke subsystem]' \ '(-1 -t)-T[disable pseudo-tty allocation (protocol version 2 only)]' \ '(-T)-t[force pseudo-tty allocation]' \ '-V[show version number]' \ - '(-q)*-v[verbose mode]' \ + '(-q)*-v[verbose mode (multiple increase verbosity, up to 3)]' \ '-W[forward standard input and output to host]:stdinout forward:->hostport' \ '-w[request tunnel device forwarding]:local_tun[\:remote_tun] (integer or "any"):' \ '(-x -Y)-X[enable (untrusted) X11 forwarding]' \ @@ -105,7 +108,7 @@ _ssh () { ;; ssh-keygen) cmds=( -p -i -e -y -c -l -B -D -U ) - _arguments \ + _arguments -s \ '-q[silence ssh-keygen]' \ "($cmds -P)-b[specify number of bits in key]:bits in key" \ "($cmds -P)-t[specify the type of the key to create]:key type:(rsa1 rsa dsa ecdsa ed25519)" \ @@ -147,17 +150,36 @@ _ssh () { case "$lstate" in option) if compset -P '*='; then - case "$IPREFIX" in - *(#i)(afstokenpassing|batchmode|challengeresponseauthentication|checkhostip|clearallforwardings|compression|enablesshkeysign|exitonforwardfailure|fallbacktorsh|forward(agent|x11)|forwardx11trusted|gatewayports|gssapiauthentication|gssapidelegatecredentials|gssapitrustdns|hashknownhosts|hostbasedauthentication|identitiesonly|kbdinteractiveauthentication|(tcp|)keepalive|nohostauthenticationforlocalhost|passwordauthentication|permitlocalcommand|pubkeyauthentication|rhosts(|rsa)authentication|rsaauthentication|usersh|kerberos(authentication|tgtpassing)|useprivilegedport|visualhostkey)=*) + case "${IPREFIX#-o}" in + (#i)(ciphers|macs|kexalgorithms|hostkeyalgorithms|pubkeyacceptedkeytypes|hostbasedkeytypes)=) + if ! compset -P +; then + _wanted append expl 'append to default' compadd + && ret=0 + fi + ;; + esac + case "${IPREFIX#-o}" in + (#i)(afstokenpassing|batchmode|canonicalizefallbacklocal|challengeresponseauthentication|checkhostip|clearallforwardings|compression|enablesshkeysign|exitonforwardfailure|fallbacktorsh|forward(agent|x11)|forwardx11trusted|gatewayports|gssapiauthentication|gssapidelegatecredentials|gssapitrustdns|hashknownhosts|hostbasedauthentication|identitiesonly|kbdinteractiveauthentication|(tcp|)keepalive|nohostauthenticationforlocalhost|passwordauthentication|permitlocalcommand|proxyusefdpass|pubkeyauthentication|rhosts(|rsa)authentication|rsaauthentication|streamlocalbindunlink|usersh|kerberos(authentication|tgtpassing)|useprivilegedport|visualhostkey)=*) _wanted values expl 'truth value' compadd yes no && ret=0 ;; - *(#i)addressfamily=*) + (#i)addressfamily=*) _wanted values expl 'address family' compadd any inet inet6 && ret=0 ;; - *(#i)bindaddress=*) + (#i)bindaddress=*) _wanted bind-addresses expl 'bind address' _bind_addresses && ret=0 ;; - *(#i)ciphers=*) + (#i)canonicaldomains=*) + _message -e 'canonical domains (space separated)' && ret=0 + ;; + (#i)canonicalizehostname=*) + _wanted values expl 'truthish value' compadd yes no always && ret=0 + ;; + (#i)canonicalizemaxdots=*) + _message -e 'number of dots' && ret=0 + ;; + (#i)canonicalizepermittedcnames=*) + _message -e 'CNAME rule list (source_domain_list:target_domain_list, each pattern list comma separated)' && ret=0 + ;; + (#i)ciphers=*) _values -s , 'encryption cipher' \ '3des-cbc' \ 'aes128-cbc' \ @@ -178,48 +200,52 @@ _ssh () { 'rijndael-cbc@lysator.liu.se' \ && ret=0 ;; - *(#i)cipher=*) + (#i)cipher=*) _wanted values expl 'encryption cipher (protocol version 1)' \ compadd blowfish 3des des idea arcfour tss none && ret=0 ;; - *(#i)compressionlevel=*) + (#i)compressionlevel=*) _values 'compression level' {1..9} && ret=0 ;; - *(#i)connectionattempts=*) + (#i)connectionattempts=*) _message -e 'connection attempts' && ret=0 ;; - *(#i)connecttimeout=*) + (#i)connecttimeout=*) _message -e 'connection timeout' && ret=0 ;; - *(#i)controlmaster=*) + (#i)controlmaster=*) _wanted values expl 'truthish value' compadd yes no auto autoask && ret=0 ;; - *(#i)controlpath=*) + (#i)controlpath=*) _description files expl 'path to control socket' _files "$expl[@]" && ret=0 ;; - *(#i)controlpersist=*) + (#i)controlpersist=*) _message -e 'timeout' ret=0 _wanted values expl 'truth value' compadd yes no && ret=0 ;; - *(#i)escapechar=*) + (#i)escapechar=*) _message -e 'escape character (or `none'\'')' ret=0 ;; - *(#i)forwardx11timeout=*) + (#i)fingerprinthash=*) + _values 'fingerprint hash algorithm' \ + md5 ripemd160 sha1 sha256 sha384 sha512 && ret=0 + ;; + (#i)forwardx11timeout=*) _message -e 'timeout' ret=0 ;; - *(#i)globalknownhostsfile=*) + (#i)globalknownhostsfile=*) _description files expl 'global file with known hosts' _files "$expl[@]" && ret=0 ;; - *(#i)hostname=*) + (#i)hostname=*) _wanted hosts expl 'real host name to log into' _ssh_hosts && ret=0 ;; - *(#i)hostkeyalgorithms=*) - _values -s , 'host key algorithms' \ + (#i)(hostbasedkeytypes|hostkeyalgorithms|pubkeyacceptedkeytypes)=*) + _values -s , 'key types' \ 'ecdsa-sha2-nistp256-cert-v01@openssh.com' \ 'ecdsa-sha2-nistp384-cert-v01@openssh.com' \ 'ecdsa-sha2-nistp521-cert-v01@openssh.com' \ @@ -235,11 +261,14 @@ _ssh () { 'ssh-rsa' \ 'ssh-dss' && ret=0 ;; - *(#i)identityfile=*) + (#i)identityfile=*) _description files expl 'SSH identity file' _files "$expl[@]" && ret=0 ;; - *(#i)ipqos=*) + (#i)ignoreunknown=*) + _message -e 'pattern list' && ret=0 + ;; + (#i)ipqos=*) local descr if [[ $PREFIX = *\ *\ * ]]; then return 1; fi if compset -P '* '; then @@ -252,105 +281,115 @@ _ssh () { 'cs0' 'cs1' 'cs2' 'cs3' 'cs4' 'cs5' 'cs6' 'cs7' 'ef' \ 'lowdelay' 'throughput' 'reliability' && ret=0 ;; - *(#i)(local|remote)forward=*) + (#i)(local|remote)forward=*) state=forward ;; - *(#i)dynamicforward=*) + (#i)dynamicforward=*) state=dynforward ;; - *(#i)kbdinteractivedevices=*) + (#i)kbdinteractivedevices=*) _values -s , 'keyboard-interactive authentication methods' \ 'bsdauth' 'pam' 'skey' && ret=0 ;; - *(#i)kexalgorithms=*) + (#i)kexalgorithms=*) _values -s , 'KEX algorithms' \ ecdh-sha2-nistp256 ecdh-sha2-nistp384 ecdh-sha2-nistp521 \ diffie-hellman-group-exchange-sha256 \ diffie-hellman-group-exchange-sha1 \ diffie-hellman-group14-sha1 diffie-hellman-group1-sha1 && ret=0 ;; - *(#i)localcommand=*) + (#i)localcommand=*) _description commands expl 'run command locally after connecting' _command_names && ret=0 ;; - *(#i)loglevel=*) + (#i)loglevel=*) _values 'log level' QUIET FATAL ERROR INFO VERBOSE\ DEBUG DEBUG1 DEBUG2 DEBUG3 && ret=0 ;; - *(#i)macs=*) + (#i)macs=*) state=macs ;; - *(#i)numberofpasswordprompts=*) + (#i)numberofpasswordprompts=*) _message -e 'number of password prompts' ret=0 ;; - *(#i)pkcs11provider=*) + (#i)pkcs11provider=*) _description files expl 'PKCS#11 shared library' _files -g '*.so' "$expl[@]" && ret=0 ;; - *(#i)port=*) + (#i)port=*) _message -e 'port number on remote host' ret=0 ;; - *(#i)preferredauthentications=*) + (#i)preferredauthentications=*) _values -s , 'authentication method' gssapi-with-mic \ hostbased publickey keyboard-interactive password && ret=0 ;; - *(#i)protocol=*) + (#i)protocol=*) _values -s , 'protocol version' \ '1' \ '2' && ret=0 ;; - *(#i)proxycommand=*) + (#i)proxycommand=*) compset -q shift 1 words (( CURRENT-- )) _normal && ret=0 ;; - *(#i)rekeylimit=*) + (#i)rekeylimit=*) _message -e 'maximum number of bytes transmitted before renegotiating session key' ret=0 ;; - *(#i)requesttty=*) + (#i)requesttty=*) _values 'request a pseudo-tty' \ 'no[never request a TTY]' \ 'yes[always request a TTY when stdin is a TTY]' \ 'force[always request a TTY]' \ 'auto[request a TTY when opening a login session]' && ret=0 ;; - *(#i)sendenv=*) + (#i)revokedhostkeys=*) + _description files expl 'revoked host keys file' + _files "$expl[@]" && ret=0 + ;; + (#i)sendenv=*) _wanted envs expl 'environment variable' _parameters -g 'scalar*export*' && ret=0 ;; - *(#i)serveralivecountmax=*) + (#i)serveralivecountmax=*) _message -e 'number of alive messages without replies before disconnecting' ret=0 ;; - *(#i)serveraliveinterval=*) + (#i)serveraliveinterval=*) _message -e 'timeout in seconds since last data was received to send alive message' ret=0 ;; - *(#i)(stricthostkeychecking|verifyhostkeydns)=*) - _wanted values expl 'checking type' compadd yes no ask && ret=0 + (#i)streamlocalbindmask=*) + _message -e 'octal mask' && ret=0 + ;; + (#i)(stricthostkeychecking|verifyhostkeydns|updatehostkeys)=*) + _wanted values expl 'truthish value' compadd yes no ask && ret=0 + ;; + (#i)transport=*) + _values 'transport protocol' TCP SCTP && ret=0 ;; - *(#i)tunnel=*) + (#i)tunnel=*) _values 'request device forwarding' \ 'yes' \ 'point-to-point' \ 'ethernet' \ 'no' && ret=0 ;; - *(#i)tunneldevice=*) + (#i)tunneldevice=*) _message -e 'local_tun[:remote_tun] (integer or "any")' ret=0 ;; - *(#i)userknownhostsfile=*) + (#i)userknownhostsfile=*) _description files expl 'user file with known hosts' _files "$expl[@]" && ret=0 ;; - *(#i)user=*) + (#i)user=*) _wanted users expl 'user to log in as' _ssh_users && ret=0 ;; - *(#i)xauthlocation=*) + (#i)xauthlocation=*) _description files expl 'xauth program' _files "$expl[@]" -g '*(-*)' && ret=0 ;; @@ -358,10 +397,15 @@ _ssh () { else # old options are after the empty "\"-line _wanted values expl 'configure file option' \ - compadd -M 'm:{a-z}={A-Z}' -S '=' - \ + compadd -M 'm:{a-z}={A-Z}' -q -S '=' - \ AddressFamily \ BatchMode \ BindAddress \ + CanonicalDomains \ + CanonicalizeFallbackLocal \ + CanonicalizeHostname \ + CanonicalizeMaxDots \ + CanonicalizePermittedCNAMEs \ ChallengeResponseAuthentication \ CheckHostIP \ Cipher \ @@ -378,6 +422,7 @@ _ssh () { EnableSSHKeysign \ EscapeChar \ ExitOnForwardFailure \ + FingerprintHash \ ForwardAgent \ ForwardX11 \ ForwardX11Timeout \ @@ -390,11 +435,13 @@ _ssh () { HashKnownHosts \ Host \ HostbasedAuthentication \ + HostbasedKeyTypes \ HostKeyAlgorithms \ HostKeyAlias \ HostName \ IdentitiesOnly \ IdentityFile \ + IgnoreUnknown \ IPQoS \ KbdInteractiveAuthentication \ KbdInteractiveDevices \ @@ -412,19 +459,26 @@ _ssh () { PreferredAuthentications \ Protocol \ ProxyCommand \ + ProxyUseFdpass \ + PubkeyAcceptedKeyTypes \ PubkeyAuthentication \ RekeyLimit \ RemoteForward \ RequestTTY \ + RevokedHostKeys \ RhostsRSAAuthentication \ RSAAuthentication \ SendEnv \ ServerAliveCountMax \ ServerAliveInterval \ + StreamLocalBindMask \ + StreamLocalBindUnlink \ StrictHostKeyChecking \ TCPKeepAlive \ + Transport \ Tunnel \ TunnelDevice \ + UpdateHostKeys \ UsePrivilegedPort \ User \ UserKnownHostsFile \ @@ -573,8 +627,8 @@ _ssh_hosts () { config="$HOME/.ssh/config" fi if [[ -r $config ]]; then - local IFS=$'\t ' key hosts host - while read key hosts; do + local key hosts host + while IFS=$'=\t ' read -r key hosts; do if [[ "$key" == (#i)host ]]; then for host in ${(z)hosts}; do case $host in diff --git a/Completion/Unix/Command/_stty b/Completion/Unix/Command/_stty index f40cd856e..b5545ebcd 100644 --- a/Completion/Unix/Command/_stty +++ b/Completion/Unix/Command/_stty @@ -14,5 +14,5 @@ else parmrk inpck istrip inlcr igncr icrnl iuclc ixon ixany ixoff \ imaxbel isig icanon xcase echo echoe echok echonl noflsh \ tostop echoctl echoprt echoke flusho pending iexten opost \ - olcuc onlcr ocrnl onocr onlret ofill ofdel + olcuc onlcr ocrnl onocr onlret ofill ofdel raw sane fi diff --git a/Completion/Unix/Command/_subversion b/Completion/Unix/Command/_subversion index 188a81367..1cffc3c04 100644 --- a/Completion/Unix/Command/_subversion +++ b/Completion/Unix/Command/_subversion @@ -50,9 +50,27 @@ _svn () { args=( ${=${${${(M)${(f)"$(_comp_locale; _call_program options svn help $cmd)"#(*Valid options:|(#e))}:#* :*}%% #:*}/ (arg|ARG)/:arg:}/(#b)(-##)([[:alpha:]]##) \[--([a-z-]##)\](:arg:)#/(--$match[3])$match[1]$match[2]$match[4] ($match[1]$match[2])--$match[3]$match[4]} ) + while (( idx=$args[(I)*--accept:arg:] )); do + args[(I)*--accept:arg:]=( --accept':automatic conflict resolution action:((working\:working base\:base '"`for i j in p postpone mc mine-conflict tc theirs-conflict mf mine-full tf theirs-full e edit l launch; print -rn $i\\\\:$j $j\\\\:$j "" `"'))' ) + done while (( idx=$args[(I)*--c(l|hangelist):arg:] )); do args[(I)*--c(l|hangelist):arg:]=( \*{--cl,--changelist}':change list:_svn_changelists' ) done + while (( idx=$args[(I)*--config-dir:arg:] )); do + args[(I)*--config-dir:arg:]=( --config-dir':config dir:_directories' ) + done + while (( idx=$args[(I)*--depth:arg:] )); do + args[(I)*--depth:arg:]=( --depth':operation depth (how far to recurse):(empty files immediates infinity)' ) + done + while (( idx=$args[(I)*(-F|--file):arg:] )); do + args[(I)*(-F|--file):arg:]=( '(-F --file)'{-F,--file}':log message file:_files' ) + done + while (( idx=$args[(I)*--set-depth:arg:] )); do + args[(I)*--set-depth:arg:]=( --set-depth'[make working copy deeper or shallower]:new depth:(exclude empty files immediates infinity)' ) + done + while (( idx=$args[(I)*--trust-server-cert-failures:arg:] )); do + args[(I)*--trust-server-cert-failures:arg:]=( --trust-server-cert-failures':failures:_values -s , "certificate failures to ignore" "unknown-ca[unknown authority]" "cn-mismatch[hostname mismatch]" "expired[certificate expired]" "not-yet-valid[certificate not yet valid]" "other[all other failures]"' ) + done _store_cache svn-${cmd}-args args fi @@ -98,7 +116,7 @@ _svn () { (mergeinfo) args[(r)--show-revs:arg:]=( '--show-revs=:revisions:(merged eligible)' ) ;; - (propget|propedit) + (propget|propedit|propdel) args+=( '1:property name:_svn_props' '2:target: _alternative "files:file:_files" "urls:URL:_svn_urls"' diff --git a/Completion/Unix/Command/_tmux b/Completion/Unix/Command/_tmux index f0cc4be37..49c2b63ed 100644 --- a/Completion/Unix/Command/_tmux +++ b/Completion/Unix/Command/_tmux @@ -40,6 +40,14 @@ # # The configuration for subcommand completions may be done in # this context: ':completion:*:*:tmux-<sub-command>:*:*' +# +# TODO: +# +# - Implement __tmux-format +# - Implement __tmux-style (possibly using existing helpers like +# __tmux-attributes and __tmux-colours) +# - in _tmux-list-panes, use __tmux-windows or __tmux-sessions +# depending on -s is among the sub-commands current command line. # Global variables; setup the first time _tmux is called. # For $_tmux_commands[] generation, see the very end of this file. @@ -51,6 +59,8 @@ _tmux_aliasmap=( attach attach-session detach detach-client has has-session + lockc lock-client + locks lock-session lsc list-clients lscm list-commands ls list-sessions @@ -67,23 +77,26 @@ _tmux_aliasmap=( breakp break-pane capturep capture-pane displayp display-panes - downp down-pane findw find-window joinp join-pane killp kill-pane killw kill-window last last-window + lastp last-pane linkw link-window lsp list-panes lsw list-windows + movep move-pane movew move-window neww new-window nextl next-layout next next-window pipep pipe-pane prev previous-window + prevl previous-layout renamew rename-window resizep resize-pane + respawnp respawn-pane respawnw respawn-window rotatew rotate-window selectl select-layout @@ -93,7 +106,6 @@ _tmux_aliasmap=( swapp swap-pane swapw swap-window unlinkw unlink-window - upp up-pane # key bindings bind bind-key @@ -117,7 +129,6 @@ _tmux_aliasmap=( # buffers clearhist clear-history - copyb copy-buffer deleteb delete-buffer lsb list-buffers loadb load-buffer @@ -131,6 +142,7 @@ _tmux_aliasmap=( lock lock-server run run-shell info server-info + wait wait-for ) # --- Sub-command functions --- @@ -154,6 +166,7 @@ function _tmux-attach-session() { local -a args args=( + '-c[specify working directory for the session]:directory:_path_files -g "*(-/)"' '-d[detach other clients attached to target session]' '-r[put the client into read-only mode]' '-t[choose a target session]:target session:__tmux-sessions' @@ -189,6 +202,8 @@ function _tmux-break-pane() { local -a args args=( '-d[do not make the new window become the active one]' + '-F[specify format of output]:format:__tmux-format__tmux-format' + '-P[print information of new window after it has been created]' '-t[choose a target pane]:panes:__tmux-panes' ) _arguments ${args} @@ -198,25 +213,80 @@ function _tmux-capture-pane() { [[ -n ${tmux_describe} ]] && print "Capture the contents of a pane to a buffer" && return local -a args args=( + '-a[use alternate screen]' '-b[choose target buffer]:target buffer:__tmux-buffers' + '-C[escape non-printable characters as octal \\ooo]' + '-e[include escape sequences for attributes etc]' + '-E[specify last line to capture. - means last line of pane]' + '-J[join wrapped lines and preserver trailing space]' + '-q[ignore errors when trying to access alternate screen]' + '-p[print data to stdout]' + '-P[only capture that is the beginning of an as-yet incomplete esc seq]' + '-S[specify start line to capture. - means first line of scrollback]' '-t[choose source pane]:source pane:__tmux-panes' ) _arguments ${args} } +function _tmux-choose-buffer() { + [[ -n ${tmux_describe} ]] && print "Put a window into buffer choice mode" && return + local -a args + args=( + '-F[specify format of output]:format:__tmux-format' + '-t[choose a target window]:sessions:__tmux-windows' + '*:: :->tmpl' + ) + _arguments ${args} && return +} + function _tmux-choose-client() { [[ -n ${tmux_describe} ]] && print "Put a window into client choice mode" && return - __tmux-choose-stuff + local -a args + args=( + '-F[specify format of output]:format:__tmux-format' + '-t[choose a target window]:sessions:__tmux-windows' + '*:: :->tmpl' + ) + _arguments ${args} && return } function _tmux-choose-session() { [[ -n ${tmux_describe} ]] && print "Put a window into session choice mode" && return - __tmux-choose-stuff + local -a args + args=( + '-F[specify format of output]:format:__tmux-format' + '-t[choose a target window]:sessions:__tmux-windows' + '*:: :->tmpl' + ) + _arguments ${args} && return +} + +function _tmux-choose-tree() { + [[ -n ${tmux_describe} ]] && print "Put a window into tree choice mode" && return + local -a args + args=( + '-b[override default session command]:session-command:' + '-c[override default window command]:window-command:' + '-S[specify session format]:session-format:__tmux-formats' + '-s[choose among sessions]' + '-t[choose a target window]:sessions:__tmux-windows' + '-u[show generated tree uncollapsed at startup]' + '-W[specify window format]:window-format:__tmux-formats' + '-w[choose among windows]' + '*:: :->tmpl' + ) + _arguments ${args} && return } function _tmux-choose-window() { [[ -n ${tmux_describe} ]] && print "Put a window into window choice mode" && return - __tmux-choose-stuff + local -a args + args=( + '-F[specify format of output]:format:__tmux-format' + '-t[choose a target window]:sessions:__tmux-windows' + '*:: :->tmpl' + ) + _arguments ${args} && return } function _tmux-clear-history() { @@ -238,6 +308,7 @@ function _tmux-command-prompt() { local state local -a args args=( + '-I[comma separated list of initial inputs]:initial-text:->ilist' '-p[list of prompts]:prompts:->plist' '-t[choose a target client]:clients:__tmux-clients' '*:: :->tmpl' @@ -246,6 +317,9 @@ function _tmux-command-prompt() { if [[ ${state} == 'plist' ]]; then _message "comma seperated list of prompts" return + elif [[ ${state} == 'ilist' ]]; then + _message "comma seperated list of initial text" + return fi __tmux-lastarg ${state} 'tmpl' 1 "command template" } @@ -255,46 +329,16 @@ function _tmux-confirm-before() { local state local -a args args=( + '-p[specify prompt]:prompt:->prompt' '-t[choose a target client]:clients:__tmux-clients' '*:: :->command_and_args' ) _arguments -C ${args} && return - __tmux-lastarg ${state} 'command_and_args' 1 "command string" -} - -function _tmux-copy-buffer() { - [[ -n ${tmux_describe} ]] && print "Copy session paste buffers" && return - local state session - local -a args - local -ax bopts - - args=( - '-a[choose a source buffer index]:buffer:->srcbuf' - '-b[choose a destination buffer index]:buffer:->dstbuf' - '-s[choose a source session]:session:->srcsession' - '-t[choose a destination session]:session:->dstsession' - ) - _arguments ${args} - - case ${state} in - ((src|dst)session) - __tmux-sessions - return - ;; - (srcbuf) - session="$(__tmux-get-optarg -s "${words[@]}")" - ;; - (srcbuf) - session="$(__tmux-get-optarg -t "${words[@]}")" - ;; - esac - if [[ -n ${session} ]]; then - bopts=( -t ${session} ) - __tmux-buffers + if [[ ${state} == 'prompt' ]]; then + _message 'prompt string' return fi - bopts=() - __tmux-buffers + __tmux-lastarg ${state} 'command_and_args' 1 "command string" } function _tmux-copy-mode() { @@ -309,39 +353,20 @@ function _tmux-copy-mode() { function _tmux-delete-buffer() { [[ -n ${tmux_describe} ]] && print "Delete a paste buffer" && return - local state session local -a args - local -ax bopts - - args=( - '-b[choose a target buffer index]:panes:->buffer' - '-t[choose a target session]:panes:->session' - ) - _arguments ${args} - - case ${state} in - (session) - __tmux-sessions - return - ;; - (buffer) - session="$(__tmux-get-optarg -t "${words[@]}")" - ;; - (*) return ;; - esac - if [[ -n ${session} ]]; then - bopts=( -t ${session} ) - __tmux-buffers - return - fi - bopts=() - __tmux-buffers + args=('-b[choose a target buffer index]:buffers:__tmux-buffers') + _arguments ${args} && return } function _tmux-detach-client() { [[ -n ${tmux_describe} ]] && print "Detach a client from the server" && return local -a args - args=('-t[choose a target client]:clients:__tmux-clients') + args=( + '-a[kill all clients except for the named by -t]' + '-P[send SIGHUP to parent process]' + '-s[choose a target session and kill its clients]:sessions:__tmux-sessions' + '-t[choose a target client]:clients:__tmux-clients' + ) _arguments ${args} } @@ -349,6 +374,7 @@ function _tmux-display-message() { [[ -n ${tmux_describe} ]] && print "Display a message in the status line" && return local -a args args=( + '-c[choose a target client]:clients:__tmux-clients' '-p[print message to stdout]' '-t[choose a target client]:clients:__tmux-clients' '*:: :->msg' @@ -364,18 +390,15 @@ function _tmux-display-panes() { _arguments ${args} } -function _tmux-down-pane() { - [[ -n ${tmux_describe} ]] && print "Move down a pane" && return - local -a args - args=('-t[choose a target pane]:panes:__tmux-panes') - _arguments ${args} -} - function _tmux-find-window() { [[ -n ${tmux_describe} ]] && print "Search for a pattern in windows" && return local curcontext="${curcontext}" state local -a args args=( + '-C[match visible contents]' + '-F[specify format of output]:format:__tmux-format' + '-N[match window name]' + '-T[match window title]' '-t[choose a target window]:windows:__tmux-windows' '*:: :->pattern' ) @@ -394,6 +417,8 @@ function _tmux-if-shell() { [[ -n ${tmux_describe} ]] && print "Execute a tmux command if a shell-command succeeded" && return local -a args args=( + '-b[run shell command in background]' + '-F[do not execute shell command but use it as a string-value]' '1:shell command:' '2:tmux command:' ) @@ -404,6 +429,7 @@ function _tmux-join-pane() { [[ -n ${tmux_describe} ]] && print "Split a pane and move an existing one into the new space" && return local -a args args=( + '-b[join source pane left of or above target pane]' '-d[do not make the new window become the active one]' '-h[split horizontally]' '-v[split vertically]' @@ -419,7 +445,7 @@ function _tmux-kill-pane() { [[ -n ${tmux_describe} ]] && print "Destroy a given pane" && return local -a args args=( - '-a[kill all panes, except current]' + '-a[kill all panes except the one specified by -t]' '-t[choose a target pane]:panes:__tmux-panes' ) _arguments ${args} @@ -433,17 +459,34 @@ function _tmux-kill-server() { function _tmux-kill-session() { [[ -n ${tmux_describe} ]] && print "Destroy a given session" && return local -a args - args=('-t[choose a target session]:sessions:__tmux-sessions') + args=( + '-a[kill all session except the one specified by -t]' + '-t[choose a target session]:sessions:__tmux-sessions' + ) _arguments ${args} } function _tmux-kill-window() { [[ -n ${tmux_describe} ]] && print "Destroy a given window" && return local -a args - args=('-t[choose a target window]:windows:__tmux-windows') + args=( + '-a[kill all windows except the one specified by -t]' + '-t[choose a target window]:windows:__tmux-windows' + ) _arguments ${args} } +function _tmux-last-pane() { + [[ -n ${tmux_describe} ]] && print "Select the previously selected pane" && return + local -a args + args=( + '-d[disable input to the pane]' + '-e[enable input to the pane]' + '-t[choose a session]:sessions:__tmux-sessions' + ) + _arguments ${args} && return +} + function _tmux-last-window() { [[ -n ${tmux_describe} ]] && print "Select the previously selected window" && return local -a args @@ -466,13 +509,18 @@ function _tmux-link-window() { function _tmux-list-buffers() { [[ -n ${tmux_describe} ]] && print "List paste buffers of a session" && return local -a args - args=('-t[choose a session]:sessions:__tmux-sessions') + args=('-F[specify format of output]:format:__tmux-format') _arguments ${args} && return } function _tmux-list-clients() { [[ -n ${tmux_describe} ]] && print "List clients attached to server" && return - __tmux-nothing-else + local -a args + args=( + '-F[specify format of output]:format:__tmux-format' + '-t[choose a session]:sessions:__tmux-sessions' + ) + _arguments ${args} && return } function _tmux-list-commands() { @@ -490,52 +538,43 @@ function _tmux-list-keys() { function _tmux-list-panes() { [[ -n ${tmux_describe} ]] && print "List panes of a window" && return local -a args - args=('-t[choose a window]:windows:__tmux-windows') + args=( + '-a[list all panes the server possesses]' + '-F[specify format of output]:format:__tmux-format' + '-s[if specified, -t chooses a session]' + # TODO: Use __tmux-windows or __tmux-sessions depending on -s. + '-t[choose a window]:windows:__tmux-windows' + ) _arguments ${args} && return } function _tmux-list-sessions() { [[ -n ${tmux_describe} ]] && print "List sessions managed by server" && return - __tmux-nothing-else + local -a args + args=('-F[specify format of output]:format:__tmux-format') + _arguments ${args} && return } function _tmux-list-windows() { [[ -n ${tmux_describe} ]] && print "List windows of a session" && return local -a args - args=('-t[choose a session]:sessions:__tmux-sessions') + args=( + '-a[list all windows the tmux server possesses]' + '-F[specify format of output]:format:__tmux-format' + '-t[choose a session]:sessions:__tmux-sessions' + ) _arguments ${args} && return } function _tmux-load-buffer() { [[ -n ${tmux_describe} ]] && print "Load a file into a paste buffer" && return - local state session local -a args - local -ax bopts args=( - '-b[choose a target buffer index]:panes:->buffer' - '-t[choose a target session]:panes:->session' + '-b[choose a target buffer index]:panes:__tmux-buffers' '1:file name:_files -g "*(-.)"' ) - _arguments ${args} - - case ${state} in - (session) - __tmux-sessions - return - ;; - (buffer) - session="$(__tmux-get-optarg -t "${words[@]}")" - ;; - (*) return ;; - esac - if [[ -n ${session} ]]; then - bopts=( -t ${session} ) - __tmux-buffers - return - fi - bopts=() - __tmux-buffers + _arguments ${args} && return } function _tmux-lock-client() { @@ -557,12 +596,30 @@ function _tmux-lock-session() { _arguments ${args} && return } +function _tmux-move-pane() { + [[ -n ${tmux_describe} ]] && print "Move a pane into a new space" && return + local -a args + args=( + '-b[join source pane left of or above target pane]' + '-d[do not make the new window become the active one]' + '-h[split horizontally]' + '-v[split vertically]' + '-l[define new pane'\''s size]: :_guard "[0-9]#" "numeric value"' + '-p[define new pane'\''s size in percent]: :_guard "[0-9]#" "numeric value"' + '-s[choose source pane]:window:__tmux-panes' + '-t[choose target pane]:window:__tmux-panes' + ) + _arguments ${args} && return +} + function _tmux-move-window() { [[ -n ${tmux_describe} ]] && print "Move a window to another" && return local -a args args=( '-d[do not make the new window become the active one]' + '-k[kill the target window if it exists]' '-s[choose source window]:window:__tmux-windows' + '-r[renumber windows in session in sequential order]' '-t[choose destination window]:window:__tmux-windows' ) _arguments ${args} @@ -572,11 +629,17 @@ function _tmux-new-session() { [[ -n ${tmux_describe} ]] && print "Create a new session" && return local -a args args=( - '-d[do not attach new session to current terminal]' '-A[attach to existing session if it already exists]' + '-c[specify working directory for the session]:directory:_path_files -g "*(-/)"' + '-d[do not attach new session to current terminal]' + '-D[in case of -A behave like attach-session'\''s -d]' + '-F[specify format of output]:format:__tmux-format' '-n[name the initial window]:window name' + '-P[print information about new session after it is created]' '-s[name the session]:session name:__tmux-sessions' '-t[specify target session]:sessions:__tmux-sessions' + '-x[specify width]:width:_guard "[0-9]#" "numeric value"' + '-y[specify height]:height:_guard "[0-9]#" "numeric value"' '*:: :_command' ) _arguments -s ${args} @@ -586,9 +649,13 @@ function _tmux-new-window() { [[ -n ${tmux_describe} ]] && print "Create a new window" && return local -a args args=( + '-a[insert new window at next free index from -t]' + '-c[specify working directory for the session]:directory:_path_files -g "*(-/)"' '-d[do not make the new window become the active one]' + '-F[specify format of output]:format:__tmux-format' '-k[destroy it if the specified window exists]' '-n[specify a window name]:window name:' + '-P[print information about new window after it is created]' '-t[specify target window]:windows:__tmux-windows' '*:: :_command' ) @@ -606,7 +673,7 @@ function _tmux-next-window() { [[ -n ${tmux_describe} ]] && print "Move to the next window in a session" && return local -a args args=( - '-a[move to the next window with activity]' + '-a[move to the next window with an alert]' '-t[choose target session]:session:__tmux-sessions' ) _arguments ${args} @@ -616,9 +683,11 @@ function _tmux-paste-buffer() { [[ -n ${tmux_describe} ]] && print "Insert a paste buffer into the window" && return local -a args args=( + '-b[choose buffer]:source buffer:__tmux-buffers' '-d[remove buffer from stack after pasting]' + '-p[use bracketed paste mode if the application requested it]' '-r[do not replace LF with CR when pasting]' - '-b[choose buffer]:source buffer:__tmux-buffers' + '-s[specify separator]:separator:' '-t[choose target window]:window:__tmux-windows' ) _arguments ${args} @@ -647,7 +716,7 @@ function _tmux-previous-window() { [[ -n ${tmux_describe} ]] && print "Move to the previous window in a session" && return local -a args args=( - '-a[move to the previous window with activity]' + '-a[move to the previous window with an alert]' '-t[choose target session]:session:__tmux-sessions' ) _arguments ${args} @@ -656,7 +725,10 @@ function _tmux-previous-window() { function _tmux-refresh-client() { [[ -n ${tmux_describe} ]] && print "Refresh a client" && return local -a args - args=('-t[choose target client]:client:__tmux-clients') + args=( + '-S[Only update the client'\''s status bar]' + '-t[choose target client]:client:__tmux-clients' + ) _arguments ${args} } @@ -690,11 +762,25 @@ function _tmux-resize-pane() { '-R[resize to the right]' '-U[resize upward]' '-t[choose target pane]:pane:__tmux-panes' + '-x[specify width]:width:_guard "[0-9]#" "numeric value"' + '-y[specify height]:height:_guard "[0-9]#" "numeric value"' + '-Z[toggle zoom of pane]' '1::adjustment (defaults to one):_guard "[0-9]#" "numeric value"' ) _arguments ${args} } +function _tmux-respawn-pane() { + [[ -n ${tmux_describe} ]] && print "Reuse a pane in which a command has exited" && return + local -a args + args=( + '-k[kill window if it is in use]' + '-t[choose target pane]:window:__tmux-pane' + '*::command:_command' + ) + _arguments ${args} +} + function _tmux-respawn-window() { [[ -n ${tmux_describe} ]] && print "Reuse a window in which a command has exited" && return local -a args @@ -719,43 +805,31 @@ function _tmux-rotate-window() { function _tmux-run-shell() { [[ -n ${tmux_describe} ]] && print "Execute a command without creating a new window" && return - _command + local -a args + args=( + '-b[run shell command in background]' + '-t[choose target pane]:pane:__tmux-panes' + '*::command:_command' + ) + _arguments ${args} } function _tmux-save-buffer() { [[ -n ${tmux_describe} ]] && print "Save a paste buffer to a file" && return - local state session local -a args - local -ax bopts args=( - '-b[choose a target buffer index]:buffer:->buffer' - '-t[choose a target session]:buffer:->session' + '-a[append to rather than overwriting file]' + '-b[choose a target buffer index]:buffer:__tmux-buffers' ) - _arguments ${args} - - case ${state} in - (session) - __tmux-sessions - return - ;; - (buffer) - session="$(__tmux-get-optarg -t "${words[@]}")" - ;; - (*) return ;; - esac - if [[ -n ${session} ]]; then - bopts=( -t ${session} ) - __tmux-buffers - return - fi - bopts=() - __tmux-buffers + _arguments ${args} && return } function _tmux-select-layout() { [[ -n ${tmux_describe} ]] && print "Choose a layout for a window" && return args=( + '-n[behave like next-layout]' + '-p[behave like previous-layout]' '-t[choose a target window]:target window:__tmux-windows' '*::layout name:__tmux-layouts' ) @@ -765,21 +839,29 @@ function _tmux-select-layout() { function _tmux-select-pane() { [[ -n ${tmux_describe} ]] && print "Make a pane the active one in the window" && return local -a args - args=('-t[choose a target pane]:panes:__tmux-panes') - _arguments ${args} && return -} - -function _tmux-select-prompt() { - [[ -n ${tmux_describe} ]] && print "Open a prompt to enter a window index" && return - local -a args - args=('-t[choose a target client]:clients:__tmux-clients') + args=( + '-D[Move to the pane down of this]' + '-d[disable input to the pane]' + '-e[enable input to the pane]' + '-l[behave like last-pane]' + '-L[Move to the pane left of this]' + '-R[Move to the pane right of this]' + '-U[Move to the pane above this]' + '-t[choose a target pane]:panes:__tmux-panes' + ) _arguments ${args} && return } function _tmux-select-window() { [[ -n ${tmux_describe} ]] && print "Select a window" && return local -a args - args=('-t[choose a target window]:windows:__tmux-windows') + args=( + '-l[behave like last-window]' + '-n[behave like next-window]' + '-p[behave like previous-window]' + '-T[if selected window is the current behave like last-window]' + '-t[choose a target window]:windows:__tmux-windows' + ) _arguments ${args} && return } @@ -788,6 +870,8 @@ function _tmux-send-keys() { local curcontext="${curcontext}" state local -a args args=( + '-l[disable key name lookup and send data literally]' + '-R[reset terminal state]' '-t[choose a target pane]:panes:__tmux-panes' '*:: :->key' ) @@ -798,7 +882,10 @@ function _tmux-send-keys() { function _tmux-send-prefix() { [[ -n ${tmux_describe} ]] && print "Send the prefix key to a window" && return local -a args - args=('-t[choose a target pane]:panes:__tmux-panes') + args=( + '-2[send secondary prefix key]' + '-t[choose a target pane]:panes:__tmux-panes' + ) _arguments ${args} } @@ -809,33 +896,16 @@ function _tmux-server-info() { function _tmux-set-buffer() { [[ -n ${tmux_describe} ]] && print "Set contents of a paster buffer" && return - local state session + local state local -a args - local -ax bopts - args=( - '-b[choose a target buffer index]:panes:->buffer' - '-t[choose a target session]:panes:->session' + '-a[append to rather than overwriting target buffer]' + '-b[choose a target buffer index]:panes:__tmux-buffer' + '-n[specify new buffer name]:buffer-name:' + '*:: :->data' ) - _arguments ${args} - - case ${state} in - (session) - __tmux-sessions - return - ;; - (buffer) - session="$(__tmux-get-optarg -t "${words[@]}")" - ;; - (*) return ;; - esac - if [[ -n ${session} ]]; then - bopts=( -t ${session} ) - __tmux-buffers - return - fi - bopts=() - __tmux-buffers + _arguments ${args} && return + __tmux-lastarg ${state} 'data' 1 "data" } function _tmux-set-environment() { @@ -904,33 +974,9 @@ function _tmux-set-window-option() { function _tmux-show-buffer() { [[ -n ${tmux_describe} ]] && print "Display the contents of a paste buffer" && return - local state session local -a args - local -ax bopts - - args=( - '-b[choose a target buffer index]:panes:->buffer' - '-t[choose a target session]:panes:->session' - ) - _arguments ${args} - - case ${state} in - (session) - __tmux-sessions - return - ;; - (buffer) - session="$(__tmux-get-optarg -t "${words[@]}")" - ;; - (*) return ;; - esac - if [[ -n ${session} ]]; then - bopts=( -t ${session} ) - __tmux-buffers - return - fi - bopts=() - __tmux-buffers + args=('-b[choose a target buffer index]:panes:->buffer') + _arguments ${args} && return } function _tmux-show-environment() { @@ -945,7 +991,13 @@ function _tmux-show-environment() { function _tmux-show-messages() { [[ -n ${tmux_describe} ]] && print "Show client"\'"s message log" && return - args=('-t[choose target client]:client:__tmux-clients') + local -a args + args=( + '-I[show debugging information about the tmux server]' + '-J[show debugging information about running jobs]' + '-T[show debugging information about involved terminals]' + '-t[choose target client]:client:__tmux-clients' + ) _arguments ${args} } @@ -978,12 +1030,14 @@ function _tmux-split-window() { [[ -n ${tmux_describe} ]] && print "Splits a pane into two" && return local -a args args=( + '-b[create new pane left of or above target pane]' '-d[do not make the new window become the active one]' + '-F[specify format of output]:format:__tmux-format' '-h[split horizontally]' '-v[split vertically]' '-l[define new pane'\''s size]: :_guard "[0-9]#" "numeric value"' '-p[define new pane'\''s size in percent]: :_guard "[0-9]#" "numeric value"' - # Yes, __tmux_pane is correct here. The behaviour was changed + # Yes, __tmux-panes is correct here. The behaviour was changed # in recent tmux versions and makes more sense. Except that # changing the command's name might annoy users. So it stays like # this. @@ -1034,6 +1088,10 @@ function _tmux-switch-client() { local -a args args=( '-c[choose a target client]:client:__tmux-clients' + '-l[move client to last session]' + '-n[move client to next session]' + '-p[move client to previous session]' + '-r[toggle read-only flag of client]' '-t[choose a target window]:window:__tmux-windows' ) _arguments ${args} @@ -1046,6 +1104,7 @@ function _tmux-unbind-key() { ow=( "${words[@]}" ) args=( + '-a[Remove all key bindings]' '-c[kill the window if it is only in one session]' '-n[remove a non-prefix binding]' '-t[choose a key table]:key table:__tmux-key-tables' @@ -1071,11 +1130,18 @@ function _tmux-unlink-window() { _arguments ${args} } -function _tmux-up-pane() { - [[ -n ${tmux_describe} ]] && print "Move up a pane" && return +function _tmux-wait-for() { + [[ -n ${tmux_describe} ]] && print "Wait for an event or trigger it" && return + local state local -a args - args=('-t[choose a target pane]:panes:__tmux-panes') - _arguments ${args} + args=( + '-L[lock the named channel]' + '-S[send signal to channel]' + '-U[unlock the named channel]' + '*:: :->channel' + ) + _arguments ${args} && return + __tmux-lastarg ${state} 'channel' 1 "event channel" } # --- Utility functions --- @@ -1110,18 +1176,6 @@ function __tmux-bound-keys() { _describe -t keys 'keys' keys } -function __tmux-choose-stuff() { - # choose-{client,session,window} accept exactly the same arguments, so... - local curcontext="${curcontext}" state - local -a args - args=( - '-t[choose a target pane]:panes:__tmux-panes' - '*:: :->tmpl' - ) - _arguments ${args} && return - __tmux-lastarg ${state} 'tmpl' 1 "tmux command template" -} - function __tmux-clients() { local expl local -a clients @@ -1129,6 +1183,10 @@ function __tmux-clients() { _describe -t clients 'clients' clients } +function __tmux-format() { + _message 'not implemented yet' +} + function __tmux-colours() { local -a colnames colnames=( default black red green yellow blue magenta cyan white colourN:"replace N by a number between 0 and 255" ) @@ -1197,13 +1255,14 @@ function __tmux-option-guard() { int_guard='_guard "[0-9]#" "'${opt}': numeric value"' if [[ ${mode} == 'session' ]]; then options=( + 'assume-paste-time:'${int_guard} 'base-index:'${int_guard} - 'bell-action:DESC:any none current' - 'buffer-limit:'${int_guard} + 'bell-action:DESC:any none current other' + 'bell-on-alert:DESC:on off' 'default-command:MSG:command string' - 'default-path:MSG:path name' 'default-shell:MSG:shell executable' - 'default-terminal:MSG:terminal string' + 'destroy-unattached:DESC:on off' + 'detach-on-destroy:DESC:on off' 'display-panes-colour:__tmux-colours' 'display-panes-active-colour:__tmux-colours' 'display-panes-time:'${int_guard} @@ -1212,78 +1271,85 @@ function __tmux-option-guard() { 'lock-after-time:'${int_guard} 'lock-command:MSG:command string' 'lock-server:DESC:on off' - 'message-attr:__tmux-attributes' - 'message-bg:__tmux-colours' - 'message-fg:__tmux-colours' - 'message-limit:'${int_guard} - 'mouse-select-pane:DESC:on off' - 'pane-border-bg:__tmux-colours' - 'pane-border-fg:__tmux-colours' - 'pane-active-border-bg:__tmux-colours' - 'pane-active-border-fg:__tmux-colours' - 'prefix:MSG:comma-seperated key list' + 'message-command-style:__tmux-style' + 'message-style:__tmux-style' + 'mouse:DESC:on off' + 'mouse-utf8:DESC:on off' + 'prefix:MSG:primary prefix key' + 'prefix2:MSG:secondary prefix key' + 'renumber-windows:DESC:on off' 'repeat-time:'${int_guard} 'set-remain-on-exit:DESC:on off' 'set-titles:DESC:on off' 'set-titles-string:MSG:title format string' 'status:DESC:on off' - 'status-attr:__tmux-attributes' - 'status-bg:__tmux-colours' - 'status-fg:__tmux-colours' 'status-interval:'${int_guard} 'status-justify:DESC:left centre right' 'status-keys:DESC:vi emacs' 'status-left:MSG:format string' - 'status-left-attr:__tmux-attributes' - 'status-left-bg:__tmux-colours' - 'status-left-fg:__tmux-colours' 'status-left-length:'${int_guard} + 'status-left-style:__tmux-style' + 'status-position:DESC:top bottom' 'status-right:MSG:format string' - 'status-right-attr:__tmux-attributes' - 'status-right-bg:__tmux-colours' - 'status-right-fg:__tmux-colours' 'status-right-length:'${int_guard} + 'status-right-style:__tmux-style' + 'status-style:__tmux-style' 'status-utf8:DESC:on off' - 'terminal-overrides:MSG:overrides string' 'update-environment:MSG:string listing env. variables' 'visual-activity:DESC:on off' 'visual-bell:DESC:on off' - 'visual-content:DESC:on off' + 'visual-silence:DESC:on off' + 'word-separators:MSG:separator string' ) elif [[ ${mode} == 'server' ]]; then options=( + 'buffer-limit:'${int_guard} + 'default-terminal:MSG:terminal string' 'escape-time:'${int_guard} + 'exit-unattached:DESC:on off' + 'focus-events:DESC:on off' + 'history-file:_path-files -g "*(-.)"' + 'message-limit:'${int_guard} 'quiet:DESC:on off' + 'set-clipboard:DESC:on off' + 'terminal-overrides:MSG:overrides string' ) else options=( 'aggressive-resize:DESC:on off' + 'allow-rename:DESC:on off' 'alternate-screen:DESC:on off' 'automatic-rename:DESC:on off' + 'automatic-rename-format:DESC:__tmux-format' 'clock-mode-colour:__tmux-colours' 'clock-mode-style:DESC:12 24' 'force-height:'${int_guard} 'force-width:'${int_guard} 'main-pane-height:'${int_guard} 'main-pane-width:'${int_guard} - 'mode-attr:__tmux-attributes' - 'mode-bg:__tmux-colours' - 'mode-fg:__tmux-colours' 'mode-keys:DESC:vi emacs' - 'mode-mouse:DESC:on off' + 'mode-style:__tmux-style' 'monitor-activity:DESC:on off' - 'monitor-content:MSG:fnmatch(3) pattern' + 'monitor-silence:DESC:on off' + 'other-pane-height:'${int_guard} + 'other-pane-width:'${int_guard} + 'pane-active-border-style:__tmux-style' + 'pane-base-index:'${int_guard} + 'pane-border-style:__tmux-style' 'remain-on-exit:DESC:on off' 'synchronize-panes:DESC:on off' 'utf8:DESC:on off' - 'window-status-attr:__tmux-attributes' - 'window-status-bg:__tmux-colours' - 'window-status-current-attr:__tmux-attributes' - 'window-status-current-bg:__tmux-colours' - 'window-status-current-fg:__tmux-colours' + 'window-active-style:__tmux-style' + 'window-status-activity-style:__tmux-style' + 'window-status-bell-style:__tmux-style' 'window-status-current-format:MSG:status format string' - 'window-status-fg:__tmux-colours' + 'window-status-current-style:__tmux-style' 'window-status-format:MSG:status format string' + 'window-status-last-style:__tmux-style' + 'window-status-separator:MSG:separator string' + 'window-status-style:__tmux-style' + 'window-style:__tmux-style' + 'wrap-seach:DESC:on off' 'xterm-keys:DESC:on off' ) fi @@ -1310,16 +1376,17 @@ function __tmux-option-guard() { esac } -function __tmux-options() { - local -a tmux_options - tmux_options=( +function __tmux-session-options() { + local -a tmux_session_options + tmux_session_options=( + 'assume-paste-time:assume keys are pasted instead of typed if this fast' 'base-index:define where to start numbering' 'bell-action:set action on window bell' - 'buffer-limit:number of buffers kept per session' + 'bell-on-alert:ring the terminal bell when an alert occurs' 'default-command:default command for new windows' - 'default-path:default working directory' 'default-shell:default shell executable' - 'default-terminal:default terminal definition string' + 'destroy-unattached:destroy session if no client is attached' + 'detach-on-destroy:detach client if attached session is destroyed' 'display-panes-colour:colour used for display-panes' 'display-panes-active-colour:colour for active pane in display-panes' 'display-panes-time:time (in msecs) of display-panes output' @@ -1328,45 +1395,37 @@ function __tmux-options() { 'lock-after-time:lock sessions after N seconds' 'lock-command:command to run for locking a client' 'lock-server:make lock-after-time lock the server instead of sessions' - 'message-attr:set status line message attributes' - 'message-bg:set status line message background colour' - 'message-fg:set status line message foreground colour' - 'message-limit:set size of message log per client' - 'mouse-select-pane:make mouse clicks select window panes' - 'pane-border-bg:set pane border foreground colour' - 'pane-border-fg:set pane border background colour' - 'pane-active-border-bg:set active pane border foreground colour' - 'pane-active-border-fg:set active pane border background colour' - 'prefix:comma seperated line of keys accepted as prefix key' + 'message-command-style:status line message command style' + 'message-style:status line message style' + 'mouse:enable mouse support' + 'mouse-utf8:request utf8 mouse support' + 'prefix:primary prefix key' + 'prefix2:secondary prefix key' + 'renumber-windows:renumber windows if a window is closed' 'repeat-time:time for multiple commands without prefix-key presses' 'set-remain-on-exit:set remain-on-exit window option' 'set-titles:try to set xterm window titles' 'set-titles-string:format used by set-titles' 'status:show or hide the status bar' - 'status-attr:status bar attributes' - 'status-bg:status bar background colour' - 'status-fg:status bar foreground colour' 'status-interval:interval (in seconds) for status bar updates' 'status-justify:position of the window list in status bar' 'status-keys:mode to use in status bar modes (vi/emacs)' 'status-left:format to use left in status bar' - 'status-left-attr:attribute for the left part of the status bar' - 'status-left-bg:background colour of the left part of the status bar' - 'status-left-fg:foreground colour of the left part of the status bar' 'status-left-length:maximum length of the left part of the status bar' + 'status-left-style:style of left part of status line' + 'status-position:status line position' 'status-right:format to use right in status bar' - 'status-right-attr:attribute for the right part of the status bar' - 'status-right-bg:background colour of the right part of the status bar' - 'status-right-fg:foreground colour of the right part of the status bar' 'status-right-length:maximum length of the right part of the status bar' + 'status-right-style:style of right part of status line' + 'status-style:style status line' 'status-utf8:assume UTF-8 sequences to appear in status bar' - 'terminal-overrides:override terminal descriptions' 'update-environment:list of variables to be copied to a session'\''s environment' 'visual-activity:display status line messages upon activity' 'visual-bell:use visual bell instead of audible' - 'visual-content:display status line messages upon content changes' + 'visual-silence:print a message if monitor-silence is on' + 'word-separators:string of characters considered word separators' ) - _describe -t tmux-options 'tmux option' tmux_options + _describe -t tmux-options 'tmux session option' tmux_session_options } function __tmux-options-complete() { @@ -1375,7 +1434,7 @@ function __tmux-options-complete() { case ${state} in name_or_value) if (( CURRENT == 1 )) && [[ ${mode} == 'session' ]]; then - __tmux-options + __tmux-session-options elif (( CURRENT == 1 )) && [[ ${mode} == 'server' ]]; then __tmux-server-options elif (( CURRENT == 1 )) && [[ ${mode} == 'window' ]]; then @@ -1413,8 +1472,16 @@ function __tmux-panes() { function __tmux-server-options() { local -a tmux_server_options tmux_server_options=( + 'buffer-limit:number of buffers kept per session' + 'default-terminal:default terminal definition string' 'escape-time:set timeout to detect single escape characters (in msecs)' + 'exit-unattached:make server exit if it has no attached clients' + 'focus-events:request focus events from terminal' + 'history-file:tmux command history file name' + 'message-limit:set size of message log per client' 'quiet:enable/disable the display of various informational messages' + 'set-clipboard:use esc sequences to set terminal clipboard' + 'terminal-overrides:override terminal descriptions' ) _describe -t tmux-server-options 'tmux server option' tmux_server_options } @@ -1435,36 +1502,47 @@ function __tmux-socket-name() { _wanted socket expl 'socket name' compadd ${expl} -- ${socks} } +function __tmux-style() { + _message 'not implemented yet' +} + function __tmux-window-options() { local -a tmux_window_options tmux_window_options=( 'aggressive-resize:aggressively resize windows' + 'allow-rename:allow programs to change window titles' 'alternate-screen:allow alternate screen feature to be used' 'automatic-rename:attempt to automatically rename windows' + 'automatic-rename-format:format for automatic renames' 'clock-mode-colour:set clock colour' 'clock-mode-style:set clock hour format (12/24)' 'force-height:force a windows to a certain height' 'force-width:force a windows to a certain width' 'main-pane-height:set height for main-* layouts' 'main-pane-width:set width for main-* layouts' - 'mode-attr:set window modes attributes' - 'mode-bg:set window modes background colour' - 'mode-fg:set window modes foreground colour' 'mode-keys:mode to use in copy and choice modes (vi/emacs)' - 'mode-mouse:use mouse in modes' + 'mode-style:set window modes style' 'monitor-activity:monitor window activity' - 'monitor-content:monitor window contents for a fnmatch(3) pattern' + 'monitor-silence:monitor window for inactivity' + 'other-pane-height:height of other panes' + 'other-pane-width:width of other panes' + 'pane-active-border-style:style of border of active pane' + 'pane-base-index:integer at which to start indexing panes' + 'pane-border-style:style of border pane' 'remain-on-exit:do not destroy windows after the program exits' 'synchronize-panes:send input to all panes of a window' 'utf8:assume UTF-8 sequences to appear in a window' - 'window-status-attr:set status line attributes for a window' - 'window-status-bg:set status line background for a window' - 'window-status-current-attr:set status line attributes for active window' - 'window-status-current-bg:set status line background for active window' - 'window-status-current-fg:set status line foreground for active window' + 'window-active-style:style of active window' + 'window-status-activity-style:style of status bar activity tag' + 'window-status-bell-style:style of status bar bell tag' 'window-status-current-format:set status line format for active window' - 'window-status-fg:set status line foreground for a window' + 'window-status-current-style:style of current window in status bar' 'window-status-format:set status line format for all but the active window' + 'window-status-last-style:style of last window in status bar' + 'window-status-separator:separator drawn between windows in status line' + 'window-status-style:general status bar style' + 'window-style:style of window' + 'wrap-search:search wrap around at the end of a pane' 'xterm-keys:generate xterm-style function key sequences' ) _describe -t tmux-window-options 'tmux window option' tmux_window_options @@ -1492,20 +1570,21 @@ function _tmux() { local curcontext="${curcontext}" local mode state ret=1 local -a args - local -x tmuxcommand - unset tmux_describe + local tmuxcommand + local tmux_describe= args=( '-2[force using 256 colours]' '-8[force using 88 colours]' '-c[execute a shell command]:command name:_command_names' + '-C[start tmux in control mode. -CC disables echo]' '-f[specify configuration file]:tmux config file:_files -g "*(-.)"' '-l[behave like a login shell]' '-L[specify socket name]:socket name:__tmux-socket-name' - '-q[do not send informational messages]' '-S[specify socket path]:server socket:_path_files -g "*(=,/)"' '-u[force using UTF-8]' '-v[request verbose logging]' + '-V[report tmux version]' '*:: :->subcommand_or_options' ) _arguments -C -s -w ${args} && ret=0 @@ -1551,7 +1630,7 @@ function _tmux() { # description generation follows; only done on 1st _tmux call. local f desc local -A rev -local -x tmux_describe +local tmux_describe tmux_describe='yes, please' for f in ${(k)_tmux_aliasmap} ; do rev+=( ${_tmux_aliasmap[$f]} $f ) @@ -1561,6 +1640,5 @@ for f in ${(M)${(k)functions}:#_tmux-*} ; do _tmux_commands+=( "${f#_tmux-}${desc:+:$desc}" ) [[ -n ${rev[${f#_tmux-}]} ]] && _tmux_aliases+=( "${rev[${f#_tmux-}]}${desc:+:$desc}" ) done -unset desc f rev tmux_describe -_tmux +_tmux "$@" diff --git a/Completion/Unix/Command/_vim b/Completion/Unix/Command/_vim index 007671be8..dbc946cb1 100644 --- a/Completion/Unix/Command/_vim +++ b/Completion/Unix/Command/_vim @@ -1,4 +1,4 @@ -#compdef vim exim gvim gex gview nvim rvim rview rgvim rgview evim eview vimdiff gvimdiff +#compdef vim gvim gex gview nvim rvim rview rgvim rgview evim eview vimdiff gvimdiff (( $+functions[_vim_files] )) || _vim_files () { diff --git a/Completion/Unix/Command/_vmstat b/Completion/Unix/Command/_vmstat new file mode 100644 index 000000000..02fa6be64 --- /dev/null +++ b/Completion/Unix/Command/_vmstat @@ -0,0 +1,83 @@ +#compdef vmstat + +local -a specs +case $OSTYPE in + *linux*) + specs=( + '(-a --active)'{-a,--active}'[active/inactive memory]' + '(-f --forks)'{-f,--forks}'[number of forks since boot]' + '(-m --slabs)'{-m,--slabs}'[slabinfo]' + '(-n --one-header)'{-n,--one-header}'[do not redisplay header]' + '(-s --stats)'{-s,--stats}'[event counter statistics]' + '(-d --disk)'{-d,--disk}'[disk statistics]' + '(-D --disk-sum)'{-D,--disk-sum}'[summarize disk statistics]' + '(-p --partition)'{-p,--partition}'[partition specific statistics]:partition:_files' + '(-S --unit)'{-S+,--unit}'[define display unit]:unit prefix:(( k\:1000 K\:1024 m\:1000000 M\:1048576 ))' + '(-w --wide)'{-w,--wide}'[wide output]' + '(-t --timestamp)'{-t,--timestamp}'[show timestamp]' + '1:delay' '2:count' + ) + ;; + freebsd*) + specs=( + '-a[include statistics about all interrupts]' + '-c[number of times to refresh the display]:count' + '-f[report on the number fork syscalls since boot and pages of virtual memory for each]' + '-h[human readable memory columns output]' + '-H[scriptable memory columns output]' + '-i[report the number of interrupts taken by devices since boot]' + '-M[source file to extract values associated with the name list from]:core:_files' + '-N[source file to extract the name list from]:system:_files' + '-m[report on the usage of kernel dynamic memory allocated using malloc(9) by type]' + '-n[change the maximum number of disks to display]:number of disks to display' + '-P[report per-cpu system/user/idle cpu statistics]' + '-p[specify which types of devices to display]: :->devices' + '-s[display the contents of the SUM structure]:sum' + '-w[delay N seconds between each display]:delay' + '-z[report on memory used by the kernel zone allocator, uma(9), by zone]' + '*:disks:_files' + ) + ;; + openbsd*) + specs=( + '-c[number of times to refresh the display]:count' + '-f[report on the number fork syscalls since boot and pages of virtual memory for each]' + '-i[report the number of interrupts taken by devices since boot]' + '-M[source file to extract values associated with the name list from]:core:_files' + '-m[report usage of kernel dynamic memory listed first by size of allocation then type of usage]' + '-N[source file to extract the name list from]:system:_files' + '-s[display the contents of the UVMEXP structure]:uvmexp' + '-t[report on the number of page in and page reclaims since boot]' + '-v[print more verbose information]' + '-w[delay N seconds between each display]:delay' + '-z[include statistics about all interrupts]' + '*:disks:_files' + ) + ;; +esac + +if (( $#specs )); then + local curcontext=$curcontext state state_descr line ret=1 + typeset -A {opt,val}_args + + _arguments -C -s -w -A '-*' : "$specs[@]" && ret=0 + + if [[ $state == devices ]]; then + local -a types + types=( + 'da[direct access devices]' 'sa[sequential access devices]' + 'printer[printers]' 'proc[processor devices]' + 'worm[write once read multiple devices]' 'cd[CD devices]' + 'scanner[scanner devices]' 'optical[optical memory devices]' + 'changer[medium changer devices]' 'comm[communication devices]' + 'array[storage array devices]' 'enclosure[enclosure services devices]' + 'floppy[floppy devices]' 'IDE[Integrated Drive Electronics devices]' + 'SCSI[Small Computer System Interface devices]' + 'other[any other device interface]' 'pass[passthrough devices]' + ) + _values -C -s , 'device type' "$types[@]" && ret=0 + fi + return ret +fi + +_default diff --git a/Completion/Unix/Command/_watch b/Completion/Unix/Command/_watch new file mode 100644 index 000000000..a8d29403f --- /dev/null +++ b/Completion/Unix/Command/_watch @@ -0,0 +1,9 @@ +#compdef watch + +# watch(1) has completely different semantics on freebsd compared to linux, hence: +case $OSTYPE in + (freebsd*|dragonfly*) _watch-snoop "$@";; + (*) _default;; +esac + +# NOTREACHED diff --git a/Completion/Unix/Command/_wget b/Completion/Unix/Command/_wget index b8ca2fd93..b6feab581 100644 --- a/Completion/Unix/Command/_wget +++ b/Completion/Unix/Command/_wget @@ -63,7 +63,7 @@ _arguments -C -s \ '--default-page=[specify default page name, normally index.html]' \ '(--adjust-extension -E)'{--adjust-extension,-E}'[save all HTML/CSS documents with proper extensions]' \ "--ignore-length[ignore \`Content-Length' header field]" \ - '*--header=:string' \ + '*--header=[send a custom HTTP header]:header:->header' \ '--max-redirect=:number' \ '--proxy-user=:user' \ '--proxy-password=:password' \ @@ -132,6 +132,7 @@ _arguments -C -s \ '--no-clobber' \ '--no-directories' \ '--no-host-directories' \ + '--no-use-server-timestamps[do not set timestamp to server provided value]' \ '--htmlify=:htmlify:' \ '--no:no:->noflags' \ '*:URL:_urls' && return 0 @@ -156,4 +157,42 @@ case "$state" in '(unix)windows' \ '(unix windows)nocontrol' ;; + header) + local -a headers + headers=( + Accept{,-{Charset,Encoding,Language,Datetime}} + Authorization + Cache-Control + Connection + Cookie + Content-{Length,MD5,Type} + Date + Expect + From + Host + If-Match + If-Modified-Since + If-None-Match + If-Range + If-Unmodified-Since + Max-Forwards + Pragma + Proxy-Authorization + Range + Referer + TE + Upgrade + User-Agent + Via + Warning + X-Requested-With + X-Do-Not-Track + DNT + X-Forwarded-For + X-ATT-DeviceId + X-Wap-Profile + ) + headers=($^headers\\:\ ) + _describe -t header 'HTTP header' headers + ;; esac diff --git a/Completion/Unix/Command/_zcat b/Completion/Unix/Command/_zcat index 6dd4ecd7b..cf927507b 100644 --- a/Completion/Unix/Command/_zcat +++ b/Completion/Unix/Command/_zcat @@ -1,6 +1,6 @@ #compdef zcat -if _pick_variant gnu=GNU unix --license; then +if _pick_variant gz='(GNU|NetBSD)' unix --license; then _gzip "$@" else _compress "$@" diff --git a/Completion/Unix/Command/_zpool b/Completion/Unix/Command/_zpool index 03ebd0642..f2116dc2e 100644 --- a/Completion/Unix/Command/_zpool +++ b/Completion/Unix/Command/_zpool @@ -86,7 +86,7 @@ _zpool() { ) if [[ $service == "zpool" ]]; then - _arguments -C -A "-*" \ + _arguments -C \ '-\?[show help information]' \ '1:subcommand:compadd -a subcmds' \ '*:: :->subcmd' && return |