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

Re: matching commands by pattern



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 13 October 2006 14:45, Frank Terbeck wrote:
> Peter Stephenson <pws@xxxxxxx>:
> > Frank Terbeck wrote:
> > > I'm trying to be able to use compsys to find all completions, that are
> > > possible as the first word of the command-line _and_ match a given
> > > pattern. Ideally, these matches should be accessible via a completion
> > > menu.
> >
> > It's easy: just set the option "globcomplete", that's what it's designed
> > for.  This makes pattern characters active during normal completion, so
> > you don't have to do anything else special to get command completion in
> > command position.
>

wow, I did not even know this one exists :)

Personally I'm using these completers:

zstyle ':completion:*' completer _oldlist _complete _match

and it does the same, but with added bonus that all other goodies (like 
matchers) work too.

> Thank you, Peter.
>
> This works. But it this way, glob_complete is in effect for every glob
> on the command-line when trying to complete.
>
> % ls *.txt<TAB>
>
> drops into a menu, rather than expanding the glob into .txt files.

Well, you can always expand using expand-word (I believe, by default bound to 
^X*). Or you could add _all_matches completer, see man page:

_all_matches
     This completer can be used to add a string consisting of all other
     matches.  As it influences later completers it must appear as the
     first completer in the list.  The list of all matches is affected
     by the avoid-completer and old-matches styles described above.

So you have choice to include either all generated matches or only part 
thereof. It really is more flexible than old way.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (GNU/Linux)

iD8DBQFFL8r9R6LMutpd94wRAirFAKCgroYaPJPcQDiO4L69qMORmKkNQQCeMW9U
u9w4zgMfO26VH51uVuxCL18=
=JmGt
-----END PGP SIGNATURE-----



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