update
This commit is contained in:
parent
128e5e7d85
commit
330c97d24d
|
@ -178,7 +178,7 @@ this will complete the items in $userdirs, aswell as a comma separated list cont
|
||||||
As with _describe, the _alternative function can itself be used in an ACTION as part of a specification for _arguments
|
As with _describe, the _alternative function can itself be used in an ACTION as part of a specification for _arguments
|
||||||
or _regex_arguments.
|
or _regex_arguments.
|
||||||
** Writing completion functions using _arguments
|
** Writing completion functions using _arguments
|
||||||
With the _arguments function you can create much more sophisticated completion functions.
|
With the _arguments function you can create more sophisticated completion functions.
|
||||||
Like the _alternative function, _arguments takes a list of specification strings as arguments.
|
Like the _alternative function, _arguments takes a list of specification strings as arguments.
|
||||||
These specification strings can be for specifying options and any corresponding option arguments (e.g. -f filename),
|
These specification strings can be for specifying options and any corresponding option arguments (e.g. -f filename),
|
||||||
or command arguments.
|
or command arguments.
|
||||||
|
@ -226,6 +226,27 @@ I have just given you the basics of _arguments specifications here, you can also
|
||||||
repeated options & arguments, options beginning with + insead of -, etc. For more details see the [[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][official documentation]].
|
repeated options & arguments, options beginning with + insead of -, etc. For more details see the [[http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System][official documentation]].
|
||||||
Also have a look at the tutorials mentioned at the end of this document, and the completion functions in the [[https://github.com/vapniks/zsh-completions/tree/master/src][src directory]].
|
Also have a look at the tutorials mentioned at the end of this document, and the completion functions in the [[https://github.com/vapniks/zsh-completions/tree/master/src][src directory]].
|
||||||
** Writing completion functions using _regex_arguments and _regex_words
|
** Writing completion functions using _regex_arguments and _regex_words
|
||||||
|
If you have a complex command line specification with several different possible argument sequences then
|
||||||
|
the _regex_arguments function may be what you need.
|
||||||
|
|
||||||
|
_regex_arguments creates a completion function whose name is given by the first argument.
|
||||||
|
Hence you need to first call _regex_arguments to create the completion function, and then call that function,
|
||||||
|
e.g. like this:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_regex_arguments _cmd OTHER_ARGS..
|
||||||
|
_cmd "$@"
|
||||||
|
#+END_SRC
|
||||||
|
|
||||||
|
The OTHER_ARGS should be sequences of specifications for matching & completing sequences of words on the command line.
|
||||||
|
These sequences can be separated by '|' to represent alternative command line specifications, and you can use
|
||||||
|
bracketing to arbitrary depth to specify alternate subsequences.
|
||||||
|
For example:
|
||||||
|
#+BEGIN_SRC sh
|
||||||
|
_regex_arguments SEQ1 '|' SEQ2 \( SEQ2a '|' SEQ2b \)
|
||||||
|
#+END_SRC
|
||||||
|
this specifies a command line matching either SEQ1, or SEQ2 followed by SEQ2a or SEQ2b.
|
||||||
|
|
||||||
|
|
||||||
*** Patterns
|
*** Patterns
|
||||||
* Testing & debugging
|
* Testing & debugging
|
||||||
To reload a completion function:
|
To reload a completion function:
|
||||||
|
|
Loading…
Reference in New Issue