Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Inserting all completions



On Jul 19, 11:30am, Danek Duvall wrote:
> Subject: Inserting all completions
> Is there a simple way to insert all the possible completions into the
> current commandline?

In the new 3.1.6 completion system, you can use

	compadd -A the_matches ...
	compadd -UQ "$the_matches"

That is, replace the current word (-U) with a single match consisting of
all strings to be inserted, but don't quote (-Q) the spaces between them.
Replace `...' above with the list of potential matches to which compadd
should compare the current word on the command line; those that actually
do match will be placed in $the_matches, quoted and ready for insertion.

Here's a trivial example of actually using this; it assumes you've run
"compinit" or otherwise installed the function-based completion system:

 function _all () {
  local -a the_matches
  compadd -A the_matches one two three four twenty thirty forty "fifty six"
  compadd -UQ "$the_matches"
 }
 compdef _all print

Now if you type

 print -l f<TAB>

you should see

 print -l four forty fifty\ six



Messages sorted by: Reverse Date, Date, Thread, Author