mirror of
git://git.code.sf.net/p/zsh/code
synced 2025-01-17 10:20:55 +01:00
zsh-workers/8720
This commit is contained in:
parent
a76b36928c
commit
3d9d13e918
32 changed files with 249 additions and 304 deletions
|
@ -1,24 +1,26 @@
|
|||
#autoload
|
||||
|
||||
# Usage:
|
||||
# _combination [-s S] V[:K1:...] Ki1[:Ni1]=Pi1 Ki2[:Ni2]=Pi2 ... Kim[:Nim]=Pim Kj[:Nj] EXPL...
|
||||
# _combination [-s S] TAG STYLE \
|
||||
# Ki1[:Ni1]=Pi1 Ki2[:Ni2]=Pi2 ... Kim[:Nim]=Pim Kj[:Nj] EXPL...
|
||||
#
|
||||
# It is assumed that V is formed as PRE_K1_..._Kn if `:K1:...' is not specified.
|
||||
# STYLE should be of the form K1-K2-...-Kn.
|
||||
#
|
||||
# Example: telnet
|
||||
#
|
||||
# Assume an user sets the variable `telnet_hosts_ports_users' as:
|
||||
# Assume an user sets the style `hosts-ports-users' as for the my-accounts
|
||||
# tag:
|
||||
#
|
||||
# telnet_hosts_ports_users=(
|
||||
# compstyle '*:telnet*:my-accounts' hosts-ports-users \
|
||||
# host0:: host1::user1 host2::user2
|
||||
# mail-server:{smtp,pop3}:
|
||||
# news-server:nntp:
|
||||
# proxy-server:8000:
|
||||
# )
|
||||
#
|
||||
#
|
||||
# `_telnet completes' hosts as:
|
||||
# `_telnet' completes hosts as:
|
||||
#
|
||||
# _combination telnet_hosts_ports_users \
|
||||
# _combination my-accounts hosts-ports-users \
|
||||
# ${options[-l]:+users=${options[-l]:q}} \
|
||||
# hosts "$expl[@]"
|
||||
#
|
||||
|
@ -28,7 +30,7 @@
|
|||
#
|
||||
# `_telnet' completes ports as:
|
||||
#
|
||||
# _combination telnet_hosts_ports_users \
|
||||
# _combination my-accounts hosts-ports-users \
|
||||
# ${options[-l]:+users=${options[-l]:q}} \
|
||||
# hosts="${line[2]:q}" \
|
||||
# ports "$expl[@]"
|
||||
|
@ -39,7 +41,7 @@
|
|||
#
|
||||
# `_telnet' completes users for an argument of option `-l' as:
|
||||
#
|
||||
# _combination telnet_hosts_ports_users \
|
||||
# _combination my-accounts hosts-ports-users \
|
||||
# ${line[2]:+hosts="${line[2]:q}"} \
|
||||
# ${line[3]:+ports="${line[3]:q}"} \
|
||||
# users "$expl[@]"
|
||||
|
@ -48,7 +50,7 @@
|
|||
# the port argument if they are exist. And if it is failed, `_users' is
|
||||
# called.
|
||||
|
||||
local sep var keys pats key num tmp
|
||||
local sep tag style keys pats key num tmp
|
||||
|
||||
if [[ "$1" = -s ]]; then
|
||||
sep="$2"
|
||||
|
@ -57,16 +59,11 @@ else
|
|||
sep=:
|
||||
fi
|
||||
|
||||
var=$1
|
||||
shift
|
||||
tag="$1"
|
||||
style="$2"
|
||||
shift 2
|
||||
|
||||
if [[ $var = *:* ]]; then
|
||||
keys=( ${(s/:/)var} )
|
||||
shift keys
|
||||
var="${var%%:*}"
|
||||
else
|
||||
keys=( "${(@s:_:)${var#*_}}" )
|
||||
fi
|
||||
keys=( ${(s/-/)style} )
|
||||
pats=( "${(@)keys/*/*}" )
|
||||
|
||||
while [[ "$1" = *=* ]]; do
|
||||
|
@ -81,8 +78,8 @@ key="${1%:*}"
|
|||
num="${${1##*:}:-1}"
|
||||
shift
|
||||
|
||||
if (( ${(P)+${var}} )); then
|
||||
eval "tmp=( \"\${(@M)${var}:#\${(j($sep))~pats}}\" )"
|
||||
if _style -a "$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} )"
|
||||
fi
|
||||
|
@ -92,4 +89,3 @@ if (( ${(P)+${var}} )); then
|
|||
else
|
||||
(( $+functions[_$key] )) && "_$key" "$@"
|
||||
fi
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ fi
|
|||
|
||||
_tags "$_type" || return 1
|
||||
|
||||
_style "$_type" description && _showd=yes
|
||||
_style "$_type" verbose && _showd=yes
|
||||
|
||||
_description _expl "$1"
|
||||
shift
|
||||
|
|
|
@ -6,7 +6,7 @@ _tags jobs || return 1
|
|||
|
||||
_style jobs prefix-needed && [[ "$PREFIX" != %* ]] && return 1
|
||||
_style jobs prefix-hidden && pfx=''
|
||||
_style jobs description && desc=yes
|
||||
_style jobs verbose && desc=yes
|
||||
|
||||
if [[ "$1" = -r ]]; then
|
||||
jids=( "${(@k)jobstates[(R)running*]}" )
|
||||
|
|
|
@ -21,7 +21,7 @@ elif [[ ${(Pt)${compstate[parameter]}} = array* ]]; then
|
|||
while _tags; do
|
||||
if _requested indexes -V expl 'array index'; then
|
||||
ind=( {1..${#${(P)${compstate[parameter]}}}} )
|
||||
if _style indexes description; then
|
||||
if _style indexes verbose; then
|
||||
list=()
|
||||
for i in "$ind[@]"; do
|
||||
[[ "$i" = ${PREFIX}*${SUFFIX} ]] &&
|
||||
|
|
|
@ -24,7 +24,7 @@ while _tags; do
|
|||
if _requested directory-stack -V expl 'directory stack' &&
|
||||
{ ! _style directory-stack prefix-needed ||
|
||||
[[ "$PREFIX" = [-+]* ]] }; then
|
||||
if _style directory-stack description; then
|
||||
if _style directory-stack verbose; then
|
||||
integer i
|
||||
|
||||
lines=("${PWD}" "${dirstack[@]}")
|
||||
|
|
|
@ -16,7 +16,7 @@ _style -a ps list-arguments listargs
|
|||
_style -a ps arguments args
|
||||
(( $#listargs )) || listargs=( "$args[@]" )
|
||||
|
||||
if _style processes description; then
|
||||
if _style processes verbose; then
|
||||
list=("${(@Mr:COLUMNS-1:)${(f@)$(ps $listargs 2>/dev/null)}[2,-1]:#[ ]#${PREFIX}[0-9]#${SUFFIX}[ ]*${~match}}")
|
||||
desc=(-ld list)
|
||||
else
|
||||
|
|
|
@ -13,7 +13,7 @@ _wanted directory-stack -V expl 'directory stack' || return 1
|
|||
|
||||
! _style directory-stack prefix-needed || [[ $PREFIX = [-+]* ]] || return 1
|
||||
|
||||
if _style directory-stack description; then
|
||||
if _style directory-stack verbose; then
|
||||
# get the list of directories with their canonical number
|
||||
# and turn the lines into an array, removing the current directory
|
||||
lines=("${PWD}" "${dirstack[@]}")
|
||||
|
|
|
@ -7,7 +7,7 @@ if [[ CURRENT -eq 2 ]]; then
|
|||
_wanted -C - jobs expl 'scheduled jobs' || return 1
|
||||
|
||||
lines=(${(f)"$(sched)"})
|
||||
if _style jobs description; then
|
||||
if _style jobs verbose; then
|
||||
disp=( -ld lines )
|
||||
else
|
||||
disp=()
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
local _comp_correct _correct_prompt comax
|
||||
local cfgacc cfgorig cfgps cfgins
|
||||
local curcontext="$curcontext" oldcontext
|
||||
local curcontext="${curcontext}" oldcontext
|
||||
|
||||
# Only if all global matchers have been tried.
|
||||
|
||||
|
@ -17,23 +17,21 @@ local curcontext="$curcontext" oldcontext
|
|||
|
||||
[[ "${#:-$PREFIX$SUFFIX}" -le 1 ]] && return 1
|
||||
|
||||
# Probably set initial context.
|
||||
|
||||
[[ -z "$curcontext" ]] && curcontext=':approximate'
|
||||
[[ "$curcontext" != *:correct ]] && curcontext="${curcontext}:approximate"
|
||||
|
||||
oldcontext="$curcontext"
|
||||
|
||||
_style -s '' accept cfgacc
|
||||
_style -s '' max-errors cfgacc
|
||||
_style -s '' original cfgorig
|
||||
_style -s '' prompt cfgps
|
||||
_style -s '' insert cfgins
|
||||
|
||||
# Get the number of errors to accept.
|
||||
|
||||
if [[ "$cfgacc" = *[nN]* && ${NUMERIC:-1} -ne 1 ]]; then
|
||||
if [[ "$cfgacc" = *numeric* && ${NUMERIC:-1} -ne 1 ]]; then
|
||||
# Stop if we also have a `!'.
|
||||
|
||||
[[ "$cfgacc" = *\!* ]] && return 1
|
||||
[[ "$cfgacc" = *not-numeric* ]] && return 1
|
||||
|
||||
# Prefer the numeric argument if that has a sensible value.
|
||||
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
# a normal completion function, but as one possible value for the
|
||||
# completer style.
|
||||
|
||||
local comp name curcontext="$curcontext" oldcontext
|
||||
|
||||
# Probably set initial context.
|
||||
|
||||
[[ -z "$curcontext" ]] && curcontext=':complete'
|
||||
local comp name curcontext="${curcontext}:complete" oldcontext
|
||||
|
||||
oldcontext="$curcontext"
|
||||
|
||||
|
|
|
@ -8,11 +8,7 @@
|
|||
# Supported configuration keys are the same as for `_approximate', only
|
||||
# starting with `correct'.
|
||||
|
||||
local ret=1 opm="$compstate[pattern_match]" curcontext="$curcontext"
|
||||
|
||||
# Probably set initial context.
|
||||
|
||||
[[ -z "$curcontext" ]] && curcontext=':correct'
|
||||
local ret=1 opm="$compstate[pattern_match]" curcontext="${curcontext}:correct"
|
||||
|
||||
compstate[pattern_match]='-'
|
||||
|
||||
|
|
|
@ -8,11 +8,7 @@
|
|||
# word from the line.
|
||||
|
||||
local exp word="$PREFIX$SUFFIX" group=-V expl expl2 disp orig menu prompt
|
||||
local curcontext="$curcontext" expr descr
|
||||
|
||||
# Probably set initial context.
|
||||
|
||||
[[ -z "$curcontext" ]] && curcontext=':expand'
|
||||
local curcontext="${curcontext}:expand" expr descr
|
||||
|
||||
# First, see if we should insert all *completions*.
|
||||
|
||||
|
@ -68,7 +64,7 @@ else
|
|||
expl=(-n)
|
||||
fi
|
||||
|
||||
if [[ -n "$menu" && "$menu" != *only* && "$menu" = *showall* ]]; then
|
||||
if [[ -n "$menu" && "$menu" != *only* && "$menu" = *show-all* ]]; then
|
||||
if [[ -n "$descr" ]]; then
|
||||
expl2=(-ld disp -X "${descr//\\%d/all words}")
|
||||
else
|
||||
|
|
|
@ -4,11 +4,7 @@
|
|||
# insert possible completions only after the list has been shown at
|
||||
# least once.
|
||||
|
||||
local pre suf curcontext="$curcontext" expr
|
||||
|
||||
# Probably set initial context.
|
||||
|
||||
[[ -z "$curcontext" ]] && curcontext=':list'
|
||||
local pre suf curcontext="${curcontext}:list" expr
|
||||
|
||||
# Get the strings to compare.
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ if [[ compstate[nmatches] -eq 0 &&
|
|||
compadd -UX "${format//\\%d/$str}" -n ''
|
||||
fi
|
||||
|
||||
_style '' last-prompt always && compstate[last_prompt]=yes
|
||||
_style '' last-prompt && compstate[last_prompt]=yes
|
||||
|
||||
_lastcomp=( "${(@kv)compstate}" )
|
||||
_lastcomp[completer]="$comp"
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
# expand-or-complete function because otherwise the pattern will
|
||||
# be expanded using globbing.
|
||||
|
||||
local tmp opm="$compstate[pattern_match]" ret=0 curcontext="$curcontext"
|
||||
local orig ins
|
||||
local tmp opm="$compstate[pattern_match]" ret=0 orig ins
|
||||
local curcontext="${curcontext}:match"
|
||||
|
||||
# Do nothing if we don't have a pattern or there are still global
|
||||
# match specifications to try.
|
||||
|
@ -19,12 +19,8 @@ tmp="${${:-$PREFIX$SUFFIX}#[~=]}"
|
|||
[[ "$tmp:q" = "$tmp" ||
|
||||
compstate[matcher] -ne compstate[total_matchers] ]] && return 1
|
||||
|
||||
# Probably set initial context.
|
||||
|
||||
[[ -z "$curcontext" ]] && curcontext=':match'
|
||||
|
||||
_style -s '' original orig
|
||||
_style -s '' insert ins
|
||||
_style -b '' insert-unambiguous ins
|
||||
|
||||
# Try completion without inserting a `*'?
|
||||
|
||||
|
@ -36,7 +32,7 @@ if [[ -n "$orig" ]]; then
|
|||
compstate[matcher]="$compstate[total_matchers]"
|
||||
|
||||
if (( ret )); then
|
||||
[[ "$ins" = unambig* &&
|
||||
[[ "$ins" = yes &&
|
||||
$#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] &&
|
||||
compstate[pattern_insert]=unambiguous
|
||||
return 0
|
||||
|
@ -53,7 +49,7 @@ _complete && ret=1
|
|||
compstate[pattern_match]="$opm"
|
||||
compstate[matcher]="$compstate[total_matchers]"
|
||||
|
||||
[[ ret -eq 1 && "$ins" = unambig* &&
|
||||
[[ ret -eq 1 && "$ins" = yes &&
|
||||
$#compstate[unambiguous] -ge ${#:-${PREFIX}${SUFFIX}} ]] &&
|
||||
compstate[pattern_insert]=unambiguous
|
||||
|
||||
|
|
|
@ -1,10 +1,6 @@
|
|||
#autoload
|
||||
|
||||
local curcontext="$curcontext"
|
||||
|
||||
# Probably set initial context.
|
||||
|
||||
[[ -z "$curcontext" ]] && curcontext=':menu'
|
||||
local curcontext="${curcontext}:menu"
|
||||
|
||||
# This completer is an example showing how menucompletion can be
|
||||
# implemented with the new completion system.
|
||||
|
|
|
@ -1,13 +1,8 @@
|
|||
#autoload
|
||||
|
||||
local curcontext="$curcontext" list menu
|
||||
|
||||
# Probably set initial context.
|
||||
|
||||
[[ -z "$curcontext" ]] && curcontext=':oldlist'
|
||||
local curcontext="${curcontext}:oldlist" list
|
||||
|
||||
_style -s '' list list
|
||||
_style -s '' menu menu
|
||||
|
||||
# If this is a listing widget and there is already an old list,
|
||||
# and either the style :oldlist:list is `always', or it is not `never'
|
||||
|
@ -33,16 +28,12 @@ if [[ -n $compstate[old_list] && $list != never ]]; then
|
|||
fi
|
||||
|
||||
# If this is a completion widget, and we have a completion inserted already,
|
||||
# and the style :oldlist:menu is not never, then we cycle through the
|
||||
# and the style :oldlist:menu is `true', then we cycle through the
|
||||
# existing list (even if it was generated by another widget).
|
||||
|
||||
if [[ $menu = verbose &&
|
||||
$LASTWIDGET = _verbose_list && $WIDGET != _verbose_list &&
|
||||
-z $compstate[old_insert] &&
|
||||
-n $compstate[old_list] ]]; then
|
||||
if [[ -z $compstate[old_insert] && -n $compstate[old_list] ]]; then
|
||||
compstate[old_list]=keep
|
||||
elif [[ $WIDGET = *complete(|-prefix|-word) &&
|
||||
$menu != (never|verbose) ]]; then
|
||||
elif [[ $WIDGET = *complete(|-prefix|-word) ]] && _style '' menu; then
|
||||
if [[ -n $compstate[old_insert] ]]; then
|
||||
compstate[old_list]=keep
|
||||
if [[ $WIDGET = *reverse* ]]; then
|
||||
|
|
|
@ -349,10 +349,10 @@ Have fun
|
|||
tmp="'*:urls' local ${${(qqs.:.)val}}"
|
||||
;;
|
||||
describe_options)
|
||||
tmp="'*:options' description ${(qq)val}"
|
||||
tmp="'*:options' verbose 'yes'"
|
||||
;;
|
||||
describe_values)
|
||||
tmp="'*:values' description ${(qq)val}"
|
||||
tmp="'*:values' verbose 'yes'"
|
||||
;;
|
||||
autodescribe_options)
|
||||
tmp="'*:options' auto-description ${(qq)val}"
|
||||
|
@ -412,7 +412,7 @@ compstyle '*:options' prefix-hidden yes"
|
|||
tmp="'*' completer ${${(qqs.:.)val}}"
|
||||
;;
|
||||
last_prompt)
|
||||
tmp="'*' last-prompt ${(qq)val}"
|
||||
tmp="'*' last-prompt 'yes'"
|
||||
;;
|
||||
esac
|
||||
[[ -n "$tmp" ]] && style="${style}${cmt}compstyle ${tmp}
|
||||
|
@ -426,11 +426,7 @@ compstyle '*:options' prefix-hidden yes"
|
|||
|
||||
# Very simple interface for setting styles:
|
||||
#
|
||||
# compstyle context -styles... context -styles ...
|
||||
#
|
||||
# Where context is of the form :ctxt-pats:...:tag-pat.
|
||||
#
|
||||
# This will be improved if needed. Promised.
|
||||
# compstyle pattern style values...
|
||||
|
||||
compstyle() {
|
||||
local long
|
||||
|
@ -490,7 +486,7 @@ compstyle() {
|
|||
|
||||
# Default styles. This should be executed conditionally somehow.
|
||||
|
||||
compstyle '*' description 'yes'
|
||||
compstyle '*' verbose 'yes'
|
||||
compstyle '*' prefix-needed 'yes'
|
||||
compstyle '*' prefix-hidden 'no'
|
||||
compstyle ':correct' accept '2n'
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
#compdef newgrp
|
||||
|
||||
local expl
|
||||
local expl groups
|
||||
|
||||
_wanted groups expl group || return 1
|
||||
|
||||
if (( ! $+groups )); then
|
||||
if (( ${+commands[ypcat]} )); then
|
||||
: ${(A)groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use YP
|
||||
else
|
||||
: ${(A)groups:=${${(s: :)$(</etc/group)}%%:*}}
|
||||
fi
|
||||
if ! _style -a groups groups groups; then
|
||||
(( $+_cache_groups )) ||
|
||||
if (( ${+commands[ypcat]} )); then
|
||||
: ${(A)_cache_groups:=${${(s: :)$(ypcat group.byname)}%%:*}} # If you use YP
|
||||
else
|
||||
: ${(A)_cache_groups:=${${(s: :)$(</etc/group)}%%:*}}
|
||||
fi
|
||||
|
||||
groups=( "$_cache_groups[@]" )
|
||||
fi
|
||||
|
||||
compadd "$@" "$expl[@]" - $groups
|
||||
compadd "$@" "$expl[@]" - "$groups[@]"
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
#compdef ftp ncftp ping rwho rup xping traceroute host
|
||||
|
||||
local expl
|
||||
local expl hosts
|
||||
|
||||
: ${(A)hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
|
||||
if ! _style -a hosts hosts hosts; then
|
||||
(( $+_cache_hosts )) ||
|
||||
: ${(A)_cache_hosts:=${(s: :)${(ps:\t:)${${(f)"$(</etc/hosts)"}%%\#*}##[:blank:]#[^[:blank:]]#}}}
|
||||
|
||||
hosts=( "$_cache_hosts[@]" )
|
||||
fi
|
||||
|
||||
_wanted hosts expl host &&
|
||||
compadd -M 'm:{a-zA-Z}={A-Za-z} r:|.=* r:|=*' "$@" "$expl[@]" - "$hosts[@]"
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
#autoload
|
||||
|
||||
local accounts_users_hosts
|
||||
|
||||
local varname="$words[1]_accounts"
|
||||
|
||||
if [[ ${(P)+varname} -eq 1 ]]; then
|
||||
accounts_users_hosts=( ${(P)varname} )
|
||||
else
|
||||
accounts_users_hosts=( $my_accounts )
|
||||
fi
|
||||
|
||||
_user_at_host "$@"
|
||||
_user_at_host -t my-accounts "$@"
|
||||
|
|
|
@ -1,13 +1,3 @@
|
|||
#compdef talk ntalk ytalk finger
|
||||
|
||||
local accounts_users_hosts
|
||||
|
||||
local varname="$words[1]_accounts"
|
||||
|
||||
if [[ ${(P)+varname} -eq 1 ]]; then
|
||||
accounts_users_hosts=( ${(P)varname} )
|
||||
else
|
||||
accounts_users_hosts=( $other_accounts )
|
||||
fi
|
||||
|
||||
_user_at_host "$@"
|
||||
_user_at_host -t other-accounts "$@"
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
#autoload
|
||||
|
||||
local expl
|
||||
local expl ports
|
||||
|
||||
: ${(A)ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ ]*}}
|
||||
if ! _style ports ports ports; then
|
||||
(( $+_cache_ports )) ||
|
||||
: ${(A)ports:=${${(M)${${(f)"$(</etc/services)"}:#\#*}#*/tcp}%%[ ]*}}
|
||||
|
||||
ports=( "$_cache_ports[@]" )
|
||||
fi
|
||||
|
||||
_wanted ports expl port && compadd "$@" "$expl[@]" - "$ports[@]"
|
||||
|
|
|
@ -1,16 +1,6 @@
|
|||
#compdef rlogin rsh remsh rcp
|
||||
|
||||
_rlogin () {
|
||||
local accounts_users_hosts
|
||||
|
||||
local varname="$words[1]_accounts"
|
||||
|
||||
if (( ${(P)+varname} )); then
|
||||
accounts_users_hosts=( ${(P)varname} )
|
||||
else
|
||||
accounts_users_hosts=( $my_accounts )
|
||||
fi
|
||||
|
||||
case "$words[1]" in
|
||||
rlogin)
|
||||
_arguments -s \
|
||||
|
@ -64,21 +54,21 @@ _rlogin () {
|
|||
}
|
||||
|
||||
_rlogin_users () {
|
||||
_tags users && _combination accounts_users_hosts users "$@"
|
||||
_tags users && _combination my-accounts users-hosts users "$@"
|
||||
}
|
||||
|
||||
_rlogin_hosts () {
|
||||
_tags hosts &&
|
||||
if [[ "$IPREFIX" == *@ ]]; then
|
||||
_combination accounts_users_hosts "users=${IPREFIX/@}" hosts "$@"
|
||||
_combination my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
|
||||
else
|
||||
_combination accounts_users_hosts \
|
||||
_combination my-accounts users-hosts \
|
||||
${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
_rlogin_all_hosts () {
|
||||
_tags hosts && _combination accounts_users_hosts hosts "$@"
|
||||
_tags hosts && _combination my-accounts users-hosts hosts "$@"
|
||||
}
|
||||
|
||||
_rlogin "$@"
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#compdef socket
|
||||
|
||||
# Parameter used:
|
||||
# Style used:
|
||||
#
|
||||
# socket_hosts_ports
|
||||
# The array that contains paris `host:port'.
|
||||
# hosts-ports
|
||||
# The style that contains pairs `host:port'.
|
||||
|
||||
local curcontext="$curcontext" state line expl
|
||||
typeset -A opt_args
|
||||
|
@ -41,14 +41,14 @@ arg1)
|
|||
_wanted ports expl 'port to listen' && _ports "$expl[@]"
|
||||
else
|
||||
_wanted hosts expl 'host' &&
|
||||
_combination socket_hosts_ports hosts "$expl[@]"
|
||||
_combination '' hosts-ports hosts "$expl[@]"
|
||||
fi
|
||||
;;
|
||||
|
||||
arg2)
|
||||
if (( ! $+opt_args[-s] )); then
|
||||
_wanted ports expl 'port to connect' &&
|
||||
_combination socket_hosts_ports hosts="${line[2]:q}" ports "$expl[@]"
|
||||
_combination '' hosts-ports hosts="${line[2]:q}" ports "$expl[@]"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -4,16 +4,6 @@ _ssh () {
|
|||
local curcontext="$curcontext" state lstate line ret=1 expl args tmp
|
||||
typeset -A opt_args
|
||||
|
||||
local accounts_users_hosts
|
||||
|
||||
local varname="$words[1]_accounts"
|
||||
|
||||
if (( ${(P)+varname} )); then
|
||||
accounts_users_hosts=( ${(P)varname} )
|
||||
else
|
||||
accounts_users_hosts=( $my_accounts )
|
||||
fi
|
||||
|
||||
args=()
|
||||
|
||||
# ssh-opt is a pseudo-command used to complete ssh options for `scp -o'.
|
||||
|
@ -227,14 +217,14 @@ _ssh () {
|
|||
}
|
||||
|
||||
_ssh_users () {
|
||||
_combination accounts_users_hosts users "$@"
|
||||
_combination my-accounts users-hosts users "$@"
|
||||
}
|
||||
|
||||
_ssh_hosts () {
|
||||
if [[ "$IPREFIX" == *@ ]]; then
|
||||
_combination accounts_users_hosts "users=${IPREFIX/@}" hosts "$@"
|
||||
_combination my-accounts users-hosts "users=${IPREFIX/@}" hosts "$@"
|
||||
else
|
||||
_combination accounts_users_hosts \
|
||||
_combination my-accounts users-hosts \
|
||||
${opt_args[-l]:+"users=${opt_args[-l]:q}"} hosts "$@"
|
||||
fi
|
||||
}
|
||||
|
|
|
@ -64,14 +64,14 @@ _arguments -C -s \
|
|||
case "$state" in
|
||||
hosts)
|
||||
_wanted hosts expl host &&
|
||||
_combination telnet_hosts_ports_users \
|
||||
_combination '' hosts-ports-users \
|
||||
${opt_args[-l]:+users=${opt_args[-l]:q}} \
|
||||
hosts "$expl[@]"
|
||||
;;
|
||||
|
||||
ports)
|
||||
_wanted ports expl port &&
|
||||
_combination telnet_hosts_ports_users \
|
||||
_combination '' hosts-ports-users \
|
||||
${opt_args[-l]:+users=${opt_args[-l]:q}} \
|
||||
hosts="${line[2]:q}" \
|
||||
ports "$expl[@]"
|
||||
|
@ -79,7 +79,7 @@ ports)
|
|||
|
||||
users)
|
||||
_wanted users expl user &&
|
||||
_combination telnet_hosts_ports_users \
|
||||
_combination '' hosts-ports-users \
|
||||
${line[2]:+hosts="${line[2]:q}"} \
|
||||
${line[3]:+ports="${line[3]:q}"} \
|
||||
users "$expl[@]"
|
||||
|
|
|
@ -1,13 +1,30 @@
|
|||
#autoload
|
||||
|
||||
# Complete user/host combinations. Normally this looks for the style
|
||||
# `users-hosts' for the tag `accounts'. A different tag may be given
|
||||
# with `-t tag'.
|
||||
# A `-' or `--' as the first argument is ignored.
|
||||
|
||||
local tag=accounts
|
||||
|
||||
if [[ "$1" = -t?* ]]; then
|
||||
tag="${1[3,-1]}"
|
||||
shift
|
||||
elif [[ "$1" = -t ]]; then
|
||||
tag="$2"
|
||||
shift 2
|
||||
fi
|
||||
|
||||
[[ "$1" = -(|-) ]] && shift
|
||||
|
||||
if [[ -prefix 1 *@ ]]; then
|
||||
local user=${PREFIX/@}
|
||||
local user=${PREFIX%%@*}
|
||||
|
||||
compset -P 1 '*@'
|
||||
|
||||
_wanted -C user-at hosts expl "host for $user" &&
|
||||
_combination accounts_users_hosts users="$user" hosts "$expl[@]" "$@"
|
||||
_combination "${tag}" users-hosts users="$user" hosts "$expl[@]" "$@"
|
||||
else
|
||||
_wanted users expl "user" &&
|
||||
_combination accounts_users_hosts users -S@ -q "$expl[@]" "$@"
|
||||
_combination "${tag}" users-hosts users -S@ -q "$expl[@]" "$@"
|
||||
fi
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
# If a parameter `users' exists and it is an array, we first try to
|
||||
# complete only to its elements.
|
||||
|
||||
local expl
|
||||
local expl users
|
||||
|
||||
_wanted users expl user || return 1
|
||||
|
||||
[[ "${(t)users}" = *array* ]] &&
|
||||
_style -a users users users &&
|
||||
compadd "$expl[@]" "$@" - "$users[@]" && return 0
|
||||
|
||||
compadd "$@" "$expl[@]" - "${(@k)userdirs}"
|
||||
|
|
|
@ -464,7 +464,7 @@ combined name and the name of a style is then compared to all patterns
|
|||
and the value of the style for the first matching pattern is used.
|
||||
|
||||
For example, many completion functions can generate matches in a
|
||||
simple and a verbose form and use the tt(description) style to decide
|
||||
simple and a verbose form and use the tt(verbose) style to decide
|
||||
which form should be used. To make all such functions always use the
|
||||
verbose form one can simply call
|
||||
|
||||
|
@ -472,7 +472,7 @@ example(compstyle '*' description yes)
|
|||
|
||||
in one of the startup files like tt(.zshrc) (after the call to the
|
||||
tt(compinit) function). This definition simply means that the
|
||||
tt(description) style has tt(yes) as its value in every context.
|
||||
tt(verbose) style has tt(yes) as its value in every context.
|
||||
|
||||
The completion function for the tt(kill) builtin command uses this
|
||||
style to decide if jobs and processes are listed only as job numbers
|
||||
|
@ -523,6 +523,9 @@ the number. Please tell us if you think that you have identified a tag
|
|||
that should be replaced by one of the more generic ones.)
|
||||
|
||||
startitem()
|
||||
item(tt(accounts))(
|
||||
used to look up the tt(users-hosts) style
|
||||
)
|
||||
item(tt(all-files))(
|
||||
for the names of all files
|
||||
)
|
||||
|
@ -638,6 +641,9 @@ for names of X modifiers
|
|||
item(tt(modules))(
|
||||
for modules (e.g. tt(zsh) modules)
|
||||
)
|
||||
item(tt(my-accounts))(
|
||||
used to look up the tt(users-hosts) style
|
||||
)
|
||||
item(tt(named-directories))(
|
||||
for named directories (you wouldn't have guessed that, would you?)
|
||||
)
|
||||
|
@ -650,6 +656,9 @@ for nicknames of YP maps
|
|||
item(tt(options))(
|
||||
for command options
|
||||
)
|
||||
item(tt(other-accounts))(
|
||||
used to look up the tt(users-hosts) style
|
||||
)
|
||||
item(tt(packages))(
|
||||
for packages (e.g. tt(rpm) packages)
|
||||
)
|
||||
|
@ -738,31 +747,6 @@ explain some of them only when explaining the completers that use
|
|||
them.)
|
||||
|
||||
startitem()
|
||||
item(tt(accept))(
|
||||
This is used by the tt(_approximate) completer function to determine
|
||||
the maximum number of errors to accept. The completer will try to
|
||||
generate completions by first allowing one error, then two errors, and
|
||||
so on, until either a match was found or the maximum number of errors
|
||||
given by this style has been reached.
|
||||
|
||||
If the value for this style contains a lower- or upper-case `tt(n)', the
|
||||
completer function will take any numeric argument as the
|
||||
maximum number of errors allowed. For example, with
|
||||
|
||||
example(compstyle ':approximate' accept 2n)
|
||||
|
||||
two errors will be allowed if no numeric argument is given. However,
|
||||
with a numeric argument of six (as in `tt(ESC-6 TAB)'), up to six
|
||||
errors are accepted. Hence with a value of `tt(0n)', no correcting
|
||||
completion will be attempted unless a numeric argument is given.
|
||||
|
||||
If the value contains `tt(n)' or `tt(N)' and an exclamation mark
|
||||
(`tt(!)'), tt(_approximate) will em(not) try to generate corrected
|
||||
completions when given a numeric argument, so in this case the number given
|
||||
should be greater than zero. For example, `tt(2n!)' specifies that
|
||||
correcting completion with two errors will usually be performed, but if a
|
||||
numeric argument is given, correcting completion will not be performed.
|
||||
)
|
||||
item(tt(arguments))(
|
||||
The value of this style is given to the tt(ps) command by functions
|
||||
that call it when generating process identifiers as matches.
|
||||
|
@ -820,7 +804,7 @@ generating filenames as matches to find out if the cursor will be left
|
|||
after the first ambiguous pathname component even when menucompletion
|
||||
is used.
|
||||
)
|
||||
item(tt(description))(
|
||||
item(tt(verbose))(
|
||||
This is used in several contexts to decide if only a simple or a
|
||||
verbose list of matches should be generated. For example some commands
|
||||
show descriptions for option names if this style is true.
|
||||
|
@ -864,14 +848,36 @@ This is used with the tt(matches) tag. If it is `true', matches of
|
|||
different types will be put in different groups, so that they are
|
||||
listed separately and not mixed when using menu completion.
|
||||
)
|
||||
item(tt(insert))(
|
||||
This is used by the tt(_match) completer function. If it is set to a
|
||||
string starting with tt(unambig), the tt(_completer) will start menu
|
||||
item(tt(groups))(
|
||||
A style holding the names of the groups that should be completed. If
|
||||
this is not set by the user, the group names from the YP database or
|
||||
the file `tt(/etc/group)' will be used.
|
||||
)
|
||||
item(tt(hosts))(
|
||||
A style holding the names of hosts that should be completed. If this
|
||||
is not set by the user the hostnames in `tt(/etc/hosts)' will be used.
|
||||
)
|
||||
item(tt(hosts-ports))(
|
||||
This style is used by commands that need or accept hostnames and
|
||||
ports. The strings in the value should be of the form
|
||||
`var(host)tt(:)var(port)'. These hostnames and ports are completed
|
||||
depending on the information already on the line, so that if, for
|
||||
example, the hostname is already typed, only those ports will be
|
||||
completed for which pairs with the hostname from the line exist.
|
||||
)
|
||||
item(tt(hosts-ports-users))(
|
||||
Like tt(hosts-ports) but used for commands like tt(telnet) and
|
||||
containing strings of the form `var(host)tt(:)var(port)tt(:)var(user)' .
|
||||
)
|
||||
item(tt(insert-unambiguous))(
|
||||
This is used by the tt(_match) completer function. If it is set to
|
||||
`true', the tt(_completer) will start menu
|
||||
completion only if no unambiguous string could be generated that is at
|
||||
least as long as the original string from the line.
|
||||
)
|
||||
item(tt(last-prompt))(
|
||||
This is used by the main completion function tt(_main_complete). If it
|
||||
This is used by the main completion function tt(_main_complete) with
|
||||
no particular context name. If it
|
||||
is `true', the cursor will always be moved back to the last prompt if
|
||||
that is still visible, independent of the setting of the
|
||||
tt(ALWAYS_LAST_PROMPT) option.
|
||||
|
@ -927,20 +933,45 @@ hostname, the path to the default web pages for the server and the
|
|||
directory name used by a user placing web pages within their home
|
||||
area.
|
||||
)
|
||||
item(tt(max-errors))(
|
||||
This is used by the tt(_approximate) completer function to determine
|
||||
the maximum number of errors to accept. The completer will try to
|
||||
generate completions by first allowing one error, then two errors, and
|
||||
so on, until either a match was found or the maximum number of errors
|
||||
given by this style has been reached.
|
||||
|
||||
If the value for this style contains the string `tt(numeric)', the
|
||||
completer function will take any numeric argument as the
|
||||
maximum number of errors allowed. For example, with
|
||||
|
||||
example(compstyle ':approximate' accept 2 numeric)
|
||||
|
||||
two errors will be allowed if no numeric argument is given. However,
|
||||
with a numeric argument of six (as in `tt(ESC-6 TAB)'), up to six
|
||||
errors are accepted. Hence with a value of `tt(0 numeric)', no correcting
|
||||
completion will be attempted unless a numeric argument is given.
|
||||
|
||||
If the value contains the string `tt(not-numeric)', tt(_approximate)
|
||||
will em(not) try to generate corrected
|
||||
completions when given a numeric argument, so in this case the number given
|
||||
should be greater than zero. For example, `tt(2 not-numeric)' specifies that
|
||||
correcting completion with two errors will usually be performed, but if a
|
||||
numeric argument is given, correcting completion will not be performed.
|
||||
)
|
||||
item(tt(menu))(
|
||||
This is used by the tt(_expand) completer. If it is unset or set to
|
||||
the empty string, the words resulting from expansion (if any) will
|
||||
an empty value, the words resulting from expansion (if any) will
|
||||
simply be inserted in the command line, replacing the original
|
||||
string. However, if this style is set to a non-empty string, the user
|
||||
string. However, if this style is set to a non-empty value, the user
|
||||
can cycle through the expansion as in menucompletion. Unless the value
|
||||
contains the substring `tt(only)', the user will still be offered all
|
||||
contains the string `tt(only)', the user will still be offered all
|
||||
expansions at once as one of the strings to insert in the command
|
||||
line; normally, this possibility is offered first, but if the value
|
||||
contains the substring `tt(last)', it is offered last. Also, if the
|
||||
value contains the substring `tt(sort)', the expansions will be sorted
|
||||
contains the string `tt(last)', it is offered last. Also, if the
|
||||
value contains the string `tt(sort)', the expansions will be sorted
|
||||
alphabetically, normally they are kept in the order the expansion
|
||||
produced them in. And finally, if the value contains the substring
|
||||
`tt(showall)', the string of all words will be shown in the list of
|
||||
produced them in. And finally, if the value contains the string
|
||||
`tt(show-all)', the string of all words will be shown in the list of
|
||||
expansions.
|
||||
|
||||
The tt(_oldlist) completer uses this, too. Here it controls how menu
|
||||
|
@ -948,7 +979,7 @@ completion behaves when a completion has already been inserted and the
|
|||
user types a standard completion key type such as tt(TAB). The default
|
||||
behaviour of tt(_oldlist) is that menu completion always continues
|
||||
with the existing list of completions. If this style is set to
|
||||
tt(never), however, a new completion is started if the old list was
|
||||
`false', however, a new completion is started if the old list was
|
||||
generated by a different completion command (the behaviour without the
|
||||
tt(_oldlist) completer).
|
||||
|
||||
|
@ -962,7 +993,7 @@ item(tt(original))(
|
|||
In the tt(_approximate) completer this style is used to specify
|
||||
whether the original string on which correcting completion was
|
||||
attempted is to be included in the list of possible corrections. If it
|
||||
is set to any non-empty string, the original string will be offered
|
||||
is set to any non-empty value, the original string will be offered
|
||||
when cycling through the completions. Normally it will appear as the
|
||||
first string, so that the command line does not change immediately;
|
||||
consecutive completion attempts will cycle through the corrected
|
||||
|
@ -1005,6 +1036,11 @@ Also, the function that completes color names uses this style with the
|
|||
tt(colors) tag. Here, the value should be the pathname of a file
|
||||
containing color names in the format of an X11 tt(rgb.txt) file.
|
||||
)
|
||||
item(tt(ports))(
|
||||
A style holding the service names of ports to complete. If this is
|
||||
not set by the user, the service names from `tt(/etc/services)' will
|
||||
be used.
|
||||
)
|
||||
item(tt(prefix-hidden))(
|
||||
This is used when matches with a common prefix are added (e.g. option
|
||||
names). If it is `true', this prefix will not be shown in the list of
|
||||
|
@ -1083,6 +1119,26 @@ example(compstyle ':expand' substitute '${NUMERIC:-1} != 1')
|
|||
substitution will be performed only if given an explicit numeric
|
||||
argument other than `tt(1)', as by typing `tt(ESC 2 TAB)'.
|
||||
)
|
||||
item(tt(users))(
|
||||
This may be set to a list of names that should be completed whenever
|
||||
a username is needed. If it is not set or the string on the line
|
||||
doesn't match any of the strings in this list, all usernames will be
|
||||
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
|
||||
user- and hostnames. For such commands, only the pairs from this style
|
||||
are used and if, for example, the hostname is already typed, then only
|
||||
the hostnames for which there is a pair with that username is defined.
|
||||
|
||||
If set for the tt(my-accounts) tag, this is used for commands such as
|
||||
tt(rlogin) and tt(ssh). I.e. the style should contain the names of the
|
||||
user's own accounts. With the tt(other-accounts) this is used for
|
||||
commands such as tt(talk) and tt(finger) and should contain other
|
||||
people's accounts. Finally, this may also used by some commands with
|
||||
the tt(accounts) tag.
|
||||
)
|
||||
item(tt(word))(
|
||||
To find out if listing should be performed on its own, the tt(_list)
|
||||
completer normally compares the contents of the line with the contents
|
||||
|
@ -1093,72 +1149,6 @@ the last time will not delay the generation of matches.
|
|||
)
|
||||
enditem()
|
||||
|
||||
subsect(Parameters)
|
||||
|
||||
These parameters may be set by the user to change the behavior of the
|
||||
completion system:
|
||||
|
||||
startitem()
|
||||
item(tt(users))(
|
||||
This may be set to an array of names that should be completed whenever
|
||||
a username is needed. If it is not set or the string on the line
|
||||
doesn't match any of the strings in this array, all usernames will be
|
||||
completed.
|
||||
)
|
||||
item(tt(groups))(
|
||||
An array holding the names of the groups that should be completed. If
|
||||
this is not set by the user, it will automatically be set to a list
|
||||
of group names taken from the YP database or the file `tt(/etc/group)'.
|
||||
)
|
||||
item(tt(hosts))(
|
||||
An array holding the names of hosts that should be completed. If this
|
||||
is not set by the user it will automatically be set to a list of the
|
||||
hostnames in `tt(/etc/hosts)'.
|
||||
)
|
||||
item(tt(ports))(
|
||||
An array holding the service names of ports to complete. If this is
|
||||
not set by the user, it will be set to a list of the service names
|
||||
from `tt(/etc/services)'.
|
||||
)
|
||||
item(tt(my_accounts))(
|
||||
This array is used for completion of usernames and hostnames for many
|
||||
commands, including the tt(ssh) and tt(rlogin) family. It should
|
||||
contain elements of the form `var(host)tt(:)var(user)', corresponding
|
||||
to the user's own accounts. These pairs will be used to complete names
|
||||
of hosts and usernames depending on the information already on the
|
||||
line, so that if, for example, the username is already typed, only
|
||||
those hostnames will be completed for which pairs with the username
|
||||
from the line exist.
|
||||
)
|
||||
item(tt(other_accounts))(
|
||||
Like tt(my_accounts), except that it should contain the usernames and
|
||||
hostnames of other people's accounts, for use with commands such as
|
||||
tt(talk), tt(ytalk) and tt(finger).
|
||||
)
|
||||
item(var(command)tt(_accounts))(
|
||||
Any of the commands which use the above tt(my_accounts) and
|
||||
tt(other_accounts) arrays can have this behaviour overridden by
|
||||
specifying a username/hostname array unique to that command.
|
||||
For example, if you wanted tt(rcp) to complete usernames and hostnames
|
||||
from a different set of accounts, you could set the array
|
||||
tt(rcp_accounts) with username/hostname pairs in the same format as
|
||||
tt(my_accounts).
|
||||
)
|
||||
item(tt(telnet_hosts_ports_users))(
|
||||
This array is used by the completion function for tt(telnet). It
|
||||
should contain elements of the form
|
||||
`var(host)tt(:)var(port)tt(:)var(user)'. These triples will be used to
|
||||
complete names of hosts, ports, and usernames depending on the
|
||||
information already on the line, so that if, for example, the hostname
|
||||
is already typed, only those ports and usernames will be completed for
|
||||
which triples with the hostname from the line exist.
|
||||
)
|
||||
item(tt(socket_hosts_ports))(
|
||||
Like tt(telnet_hosts_ports_users), but used for the tt(socket) command
|
||||
and containing pairs of hostnames and ports.
|
||||
)
|
||||
enditem()
|
||||
|
||||
texinode(Control Functions)(Bindable Commands)(Completion System Configuration)(Completion System)
|
||||
sect(Control Functions)
|
||||
cindex(completion system, choosing completers)
|
||||
|
@ -1309,7 +1299,7 @@ corrected completions are found, the completer will normally start
|
|||
menucompletion allowing you to cycle through these strings.
|
||||
|
||||
The exact behavior of this completer can be changed by using the
|
||||
styles tt(accept), tt(original), tt(prompt), and tt(insert), see
|
||||
styles tt(max-errors), tt(original), tt(prompt), and tt(insert), see
|
||||
ifzman(the section `Completion System Configuration' above)\
|
||||
ifnzman(noderef(Completion System Configuration)).
|
||||
|
||||
|
@ -1328,8 +1318,8 @@ different top-level context name.
|
|||
For example, with:
|
||||
|
||||
example(compstyle '*' completer _complete _correct _approximate
|
||||
compstyle ':correct' accept '2n!'
|
||||
compstyle ':approximate' accept '3n')
|
||||
compstyle ':correct' accept 2 not-numeric'
|
||||
compstyle ':approximate' accept 3 numeric)
|
||||
|
||||
correction will accept up to two errors. If a numeric argument is
|
||||
given, correction will not be performed, but correcting completion
|
||||
|
@ -2271,29 +2261,41 @@ This is alternation of two `var(spec)'s.
|
|||
enditem()
|
||||
)
|
||||
item(tt(_combination))(
|
||||
This function uses a array to represent combinations of completing texts.
|
||||
The first argument is a name of the array optionally appended completing
|
||||
field names separated by colon. If it contains no colon, it is assumed
|
||||
that the name is formed as `var(prefix)_var(fieldname)_..._var(fieldname)'
|
||||
which `var(prefix)' and `var(fieldname)'s does not contain a underscore.
|
||||
A each element of the array should be colon-separated completing texts
|
||||
which correspond to the field names. The option `tt(-s) var(sepchar)'
|
||||
can be given before the array name to change the delimiter in the array
|
||||
element from colon.
|
||||
This function is used to complete combinations of values such as pairs
|
||||
of hostnames and usernames. The possible values will be taken from the
|
||||
style whose name is given as the second argument. The first argument
|
||||
is the tag to use to do the lookup.
|
||||
|
||||
Since second argument, zero or more arguments formed as
|
||||
`var(fieldname)tt(=)var(pattern)' can be given. It restricts completion
|
||||
candidates from the array by maching a text that corresponds to
|
||||
`var(fieldname)' against to `var(pattern)'. If `tt(:)var(num)' is
|
||||
specified between `var(fieldname)' and `tt(=)', `var(num)'th field in
|
||||
named as `var(fieldname)' is used instead of the first.
|
||||
The style name should consist of multiple parts separated with
|
||||
hyphens which are then used as fieldnames. Known values for such
|
||||
fields can be given after the second argument in arguments of the form
|
||||
`var(fiels)tt(=)var(pattern)'. The first argument without a equal sign
|
||||
is taken as the name of the field for which completions should be
|
||||
generated.
|
||||
|
||||
After above arguments, completing field name should be given. It may have
|
||||
suffix `tt(:)var(num)' to use a arbitrary field instead of the first as
|
||||
above.
|
||||
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).
|
||||
|
||||
If there are no array element to match all of specified pattern and the
|
||||
function `tt(_)var(fieldname)' exists, the function is called.
|
||||
Only the values for the requested fields for which the patterns given
|
||||
in the `var(field)tt(=)var(pattern)' match the respective fields in
|
||||
the strings from the style value are generated as possible matches.
|
||||
|
||||
If no style with the given name is defined for the given tag but a
|
||||
function named with the name of the requestd field preceded by an
|
||||
underscore is defined, that function will be called to generate the
|
||||
matches. This is also done if none of the strings in the value of the
|
||||
style match all the patterns given as arguments.
|
||||
|
||||
If the same name is used for more than one field, in both the
|
||||
`var(field)tt(=)var(pattern)' and the argument that gives the field
|
||||
name to complete for, the number of the field (starting with one) may
|
||||
be given after the fieldname (separated from it by a colon).
|
||||
|
||||
All arguments after the requested fieldname are given to the
|
||||
tt(compadd) used (when generating matches from the style value) and to
|
||||
the functions for the fields if they are called.
|
||||
)
|
||||
enditem()
|
||||
|
||||
|
|
|
@ -18,9 +18,7 @@ incremental-complete-word() {
|
|||
|
||||
local key lbuf="$LBUFFER" rbuf="$RBUFFER" pmpt word
|
||||
local lastl lastr wid twid num alt post toolong
|
||||
local curcontext="$curcontext" stop brk
|
||||
|
||||
[[ -z "$curcontext" ]] && curcontext=':incremental'
|
||||
local curcontext="${curcontext}:incremental" stop brk
|
||||
|
||||
_style -s '' prompt pmpt || pmpt='incremental (%c): %u%s %l}'
|
||||
_style -s '' stop stop
|
||||
|
|
|
@ -53,9 +53,7 @@ insert-and-predict () {
|
|||
unsetopt automenu recexact
|
||||
integer curs=$CURSOR pos nchar=${#LBUFFER//[^${KEYS[-1]}]}
|
||||
local -a +h comppostfuncs
|
||||
local crs curcontext="$curcontext"
|
||||
|
||||
[[ -z "$curcontext" ] && curcontext=':predict'
|
||||
local crs curcontext="${curcontext}:predict"
|
||||
|
||||
comppostfuncs=( predict-limit-list )
|
||||
zle complete-word
|
||||
|
|
Loading…
Reference in a new issue