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

Re: Context-aware file name completion with preferences

On Sun, May 2, 2010 at 12:16, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Sat, May 1, 2010 at 1:51 PM, Mikael Puhakka <mr.progo@xxxxxxxxx> wrote:
>> Whoah! Thanks for a thorough explanation on how this works!
> You're welcome, but I can't really pretend that explanation was all
> that thorough.  There's rather a lot of details I'm not going to try
> to write out ...

Yes, well I noticed that the explanation of yours doesn't actually
allow completing the other kinds of files. I adapted one example for
PDF reading:

zstyle ':completion:*:(xpdf|epdfview|okular):*' file-patterns \
  '*.(pdf|ps):readable-files *(-/):directories' '*:all-files'

Where I had to move directories to the first set of quotes. Using and
slightly modifying the set example it wouldn't allow me to complete
directories at all. I think this version doesn't cover the case
'*:all-files' at all either. For that particular example (pdf
reading/browsing) this is excellent, for the rest, I'll wait for the

Another good example of this kind of priority completion would be
video watching. For mplayer, I'd like to prefer extensions like "avi",
"mkv" etc. But not all videos have a common extension if not extension
at all! For instance, stream dumps can be without any specific name.
This is why I find important that zsh will also complete names that
aren't preferred, if there are no good choices. Your example pushed me
towards, however. And now I have something concrete to grep and find
in the manuals. The book will hopefully answer the rest.

>> Is there any other book recommendation for mastering zsh?
> No other book, but the online user guide may be helpful (don't let the
> 2003 date on the front page worry you, it has been updated a bit more
> recently than that).
> http://zsh.sourceforge.net/Guide/zshguide.html

This one is familiar. Perhaps not the clearest or simplest guide, (I
learned the basics of Zsh using the FAQ) but as a reference quite
good. The manpages are too enormous to be learned from! But being
references they work all along well.

-- Mikael

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