GNU Info

Info Node: (zsh.info)Extended Completion

(zsh.info)Extended Completion


Next: Example Prev: Alternative Completion Up: Completion Using compctl
Enter node , (file) or (file)node

Extended Completion
===================

compctl [ -CDT ] OPTIONS -x PATTERN OPTIONS - ... -
     [ COMMAND ... ]

compctl [ -CDT ] OPTIONS [ -x PATTERN OPTIONS - ... - ]
     [ + OPTIONS [ -x ... - ] ... [+] ] [ COMMAND ... ]


The form with `-x' specifies extended completion for the commands
given; as shown, it may be combined with alternative completion using
`+'.  Each PATTERN is examined in turn; when a match is found, the
corresponding OPTIONS, as described in Note: Option Flags above, are
used to generate possible completions.  If no PATTERN matches, the
OPTIONS given before the -x are used.

Note that each pattern should be supplied as a single argument and
should be quoted to prevent expansion of metacharacters by the shell.

A PATTERN is built of sub-patterns separated by commas; it matches if
at least one of these sub-patterns matches (they are `or'ed). These
sub-patterns are in turn composed of other sub-patterns separated by
white spaces which match if all of the sub-patterns match (they are
`and'ed).  An element of the sub-patterns is of the form `C[...][...]',
where the pairs of brackets may be repeated as often as necessary, and
matches if any of the sets of brackets match (an `or').  The example
below makes this clearer.

The elements may be any of the following:

s[STRING]...
     Matches if the current word on the command line starts with one of
     the strings given in brackets.  The STRING is not removed and is
     not part of the completion.

S[STRING]...
     Like s[STRING] except that the STRING is part of the completion.

p[FROM,TO]...
     Matches if the number of the current word is between one of the
     FROM and TO pairs inclusive. The comma and TO are optional; TO
     defaults to the same value as FROM.  The numbers may be negative:
     -N refers to the N'th last word on the line.

c[OFFSET,STRING]...
     Matches if the STRING matches the word offset by OFFSET from the
     current word position.  Usually OFFSET will be negative.

C[OFFSET,PATTERN]...
     Like c but using pattern matching instead.

w[INDEX,STRING]...
     Matches if the word in position INDEX is equal to the
     corresponding STRING.  Note that the word count is made after any
     alias expansion.

W[INDEX,PATTERN]...
     Like w but using pattern matching instead.

n[INDEX,STRING]...
     Matches if the current word contains STRING.  Anything up to and
     including the INDEXth occurrence of this string will not be
     considered part of the completion, but the rest will.  INDEX may
     be negative to count from the end: in most cases, INDEX will be 1
     or -1.  For example,

          compctl -s '`users`' -x 'n[1,@]' -k hosts -- talk

     will usually complete usernames, but if you insert an @ after the
     name, names from the array HOSTS (assumed to contain hostnames,
     though you must make the array yourself) will be completed.  Other
     commands such as rcp can be handled similarly.

N[INDEX,STRING]...
     Like n except that the string will be taken as a character class.
     Anything up to and including the INDEXth occurrence of any of the
     characters in STRING will not be considered part of the completion.

m[MIN,MAX]...
     Matches if the total number of words lies between MIN and MAX
     inclusive.

r[STR1,STR2]...
     Matches if the cursor is after a word with prefix STR1.  If there
     is also a word with prefix STR2 on the command line after the one
     matched by STR1 it matches only if the cursor is before this word.
     If the comma and STR2 are omitted, it matches if the cursor is
     after a word with prefix STR1.

R[STR1,STR2]...
     Like r but using pattern matching instead.

q[STR]...
     Matches the word currently being completed is in single quotes and
     the STR begins with the letter `s', or if completion is done in
     double quotes and STR starts with the letter `d', or if completion
     is done in backticks and STR starts with a `b'.


automatically generated by info2www version 1.2.2.9