aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc_src/complete.txt
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-08-15 18:14:36 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-08-15 18:14:36 -0700
commit06400b83b188156f31ed92216ec27122d29f88cd (patch)
tree2f9cec409aba50449638c8d4361b4dafe530f3ec /doc_src/complete.txt
parentfe68d30be97853865b24ad5f5998d3e50769f860 (diff)
Support for command wrapping ("aliases")
Add the --wraps option to 'complete' and 'function'. This allows a command to (recursively) inherit the completions of a wrapped command. Fixes #393. When evaluating a completion, we inspect the entire "wrap chain" for a command, i.e. we follow the sequence of wrapping until we either hit a loop (which we silently ignore) or the end of the chain. We then evaluate completions as if the wrapping command were substituted with the wrapped command. Currently this only works for commands, i.e. 'complete --command gco --wraps git\ checkout' won't work (that would seem to encroaching on abbreviations anyways). It might be useful to show an error message for that case. The commandline builtin reflects the commandline with the wrapped command substituted in, so e.g. git completions (which inspect the command line) will just work. This sort of command line munging is also performed by 'complete -C' so it's not totally without precedent. 'alias will also now mark its generated function as wrapping the 'target.
Diffstat (limited to 'doc_src/complete.txt')
-rw-r--r--doc_src/complete.txt18
1 files changed, 17 insertions, 1 deletions
diff --git a/doc_src/complete.txt b/doc_src/complete.txt
index c2085ccb..0c1ffa91 100644
--- a/doc_src/complete.txt
+++ b/doc_src/complete.txt
@@ -1,7 +1,7 @@
\section complete complete - edit command specific tab-completions
\subsection complete-synopsis Synopsis
-<tt>complete (-c|--command|-p|--path) COMMAND [(-s|--short-option) SHORT_OPTION] [(-l|--long-option|-o|--old-option) LONG_OPTION [(-a||--arguments) OPTION_ARGUMENTS] [(-d|--description) DESCRIPTION] </tt>
+<tt>complete (-c|--command|-p|--path) COMMAND [(-s|--short-option) SHORT_OPTION] [(-l|--long-option|-o|--old-option) LONG_OPTION [(-a||--arguments) OPTION_ARGUMENTS] [(-w|--wraps) WRAPPED_COMMAND] [(-d|--description) DESCRIPTION] </tt>
\subsection complete-description Description
@@ -24,6 +24,7 @@ the fish manual.
- <tt>-u</tt> or <tt>--unauthoritative</tt> implies that there may be more options than the ones specified, and that fish should not assume that options not listed are spelling errors
- <tt>-A</tt> or <tt>--authoritative</tt> implies that there may be no more options than the ones specified, and that fish should assume that options not listed are spelling errors
- <tt>-x</tt> or <tt>--exclusive</tt> implies both <tt>-r</tt> and <tt>-f</tt>
+- <tt>-w WRAPPED_COMMAND</tt> or <tt>--wraps=WRAPPED_COMMAND</tt> causes the specified command to inherit completions from the wrapped comamnd.
Command specific tab-completions in \c fish are based on the notion
of options and arguments. An option is a parameter which begins with a
@@ -41,6 +42,14 @@ switches may all be used multiple times to specify multiple commands
which have the same completion or multiple switches accepted by a
command.
+The \c -w or \c --wraps options causes the specified command to inherit
+completions from another command. The inheriting command is said to
+"wrap" the inherited command. The wrapping command may have its own
+completions in addition to inherited ones. A command may wrap multiple
+commands, and wrapping is transitive: if A wraps B, and B wraps C,
+then A automatically inherits all of C's completions. Wrapping can
+be removed using the \c -e or \c --erase options.
+
When erasing completions, it is possible to either erase all
completions for a specific command by specifying <tt>complete -e -c
COMMAND</tt>, or by specifying a specific completion option to delete
@@ -75,3 +84,10 @@ This can be written as:
where \c __fish_contains_opt is a function that checks the commandline
buffer for the presence of a specified set of options.
+To implement an alias, use the \c -w or \c --wraps option:
+
+<tt>complete -c hub -w git</tt>
+
+Now hub inherits all of the completions from git. Note this can
+also be specified in a function declaration.
+