diff options
-rw-r--r-- | Completion/Base/_combination | 7 | ||||
-rw-r--r-- | Completion/User/_rlogin | 8 | ||||
-rw-r--r-- | Completion/User/_ssh | 6 | ||||
-rw-r--r-- | Completion/User/_user_at_host | 4 | ||||
-rw-r--r-- | Doc/Zsh/compsys.yo | 11 |
5 files changed, 21 insertions, 15 deletions
diff --git a/Completion/Base/_combination b/Completion/Base/_combination index 875d3c2cb..6b9607a27 100644 --- a/Completion/Base/_combination +++ b/Completion/Base/_combination @@ -55,6 +55,9 @@ local sep tag style keys pats key num tmp if [[ "$1" = -s ]]; then sep="$2" shift 2 +elif [[ "$1" = -s* ]]; then + sep="${1[3,-1]}" + shift else sep=: fi @@ -81,9 +84,9 @@ shift if zstyle -a ":completion:${curcontext}:$tag" "$style" tmp; then eval "tmp=( \"\${(@M)tmp:#\${(j($sep))~pats}}\" )" if (( keys[(in:num:)$key] != 1 )); then - eval "tmp=( \${tmp#\${(j(${sep}))~\${(@)\${(@)keys[2,(rn:num:)\$key]}/*/*}}$sep} )" + eval "tmp=( \${tmp#\${(j(${sep}))~\${(@)\${(@)keys[2,(rn:num:)\$key]}/*/*}}${~sep}} )" fi - tmp=( ${tmp%%$sep*} ) + tmp=( ${tmp%%${~sep}*} ) compadd "$@" - $tmp || { (( $+functions[_$key] )) && "_$key" "$@" } else diff --git a/Completion/User/_rlogin b/Completion/User/_rlogin index 738b6225f..df78bd447 100644 --- a/Completion/User/_rlogin +++ b/Completion/User/_rlogin @@ -54,21 +54,21 @@ _rlogin () { } _rlogin_users () { - _tags users && _combination my-accounts users-hosts users "$@" + _tags users && _combination -s '[:@]' my-accounts users-hosts users "$@" } _rlogin_hosts () { _tags hosts && if [[ "$IPREFIX" == *@ ]]; then - _combination my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@" + _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@" else - _combination my-accounts users-hosts \ + _combination -s '[:@]' my-accounts users-hosts \ ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@" fi } _rlogin_all_hosts () { - _tags hosts && _combination my-accounts users-hosts hosts "$@" + _tags hosts && _combination -s '[:@]' my-accounts users-hosts hosts "$@" } _rlogin "$@" diff --git a/Completion/User/_ssh b/Completion/User/_ssh index 82f959b37..ddfe6de63 100644 --- a/Completion/User/_ssh +++ b/Completion/User/_ssh @@ -223,14 +223,14 @@ _ssh () { } _ssh_users () { - _combination my-accounts users-hosts users "$@" + _combination -s '[:@]' my-accounts users-hosts users "$@" } _ssh_hosts () { if [[ "$IPREFIX" == *@ ]]; then - _combination my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@" + _combination -s '[:@]' my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@" else - _combination my-accounts users-hosts \ + _combination -s '[:@]' my-accounts users-hosts \ ${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@" fi } diff --git a/Completion/User/_user_at_host b/Completion/User/_user_at_host index 1098d2342..c7b86d385 100644 --- a/Completion/User/_user_at_host +++ b/Completion/User/_user_at_host @@ -23,8 +23,8 @@ if [[ -prefix 1 *@ ]]; then compset -P 1 '*@' _wanted -C user-at hosts expl "host for $user" && - _combination "${tag}" users-hosts users="$user" hosts "$expl[@]" "$@" + _combination -s '[:@]' "${tag}" users-hosts users="$user" hosts "$expl[@]" "$@" else _wanted users expl "user" && - _combination "${tag}" users-hosts users -S@ -q "$expl[@]" "$@" + _combination -s '[:@]' "${tag}" users-hosts users -S@ -q "$expl[@]" "$@" fi diff --git a/Doc/Zsh/compsys.yo b/Doc/Zsh/compsys.yo index 0f4fac35f..525fb70ed 100644 --- a/Doc/Zsh/compsys.yo +++ b/Doc/Zsh/compsys.yo @@ -1456,7 +1456,8 @@ completed. ) item(tt(users-hosts))( The values of this style should be of the form -`var(user)tt(:)var(host)'. It is used for commands that need pairs of +`var(user)tt(@)var(host)' or `var(user)tt(:)var(host)'. It is used for +commands that need pairs of user- and hostnames. For such commands, only the pairs from this style are used and if, for example, the username is already typed, then only the hostnames for which there is a pair with that username is defined. @@ -2637,7 +2638,7 @@ Either of two `var(spec)'s can be matched. enditem() ) findex(_combination) -item(tt(_combination) [ tt(-s) var(spec) ] var(tag) var(style) var(specs) ... var(field) var(opts) ...)( +item(tt(_combination) [ tt(-s) var(pattern) ] var(tag) var(style) var(specs) ... var(field) var(opts) ...)( This function is used to complete combinations of values such as pairs of hostnames and usernames. The possible values will be taken from the var(style) whose name is given as the second argument. The first argument @@ -2652,8 +2653,10 @@ generated. The matches generated will be taken from the value of the style. These values should contain the possible values for the combinations where -the values for the different fields are separated by colons or the -character given after the tt(-s) option to tt(_combination). +the values for the different fields are separated by colons or +characters matching the pattern given after the tt(-s) option to +tt(_combination) (normally this is used to define character classes +like the `tt(-s "[:@]")' used for the tt(users-hosts) style). Only the values for the requested fields for which the patterns given in the `var(field)tt(=)var(pattern)' match the respective fields in |