Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does the matcher-list arguments work in zsh zstyle completion?

Tags:

zshrc

I'm trying to configure my ~/.zshrc so code completion on files/dirs work as I need it. I've found various ressources online on the zstyle completion syntax, and code example but some parts of it are still black magic to me.

So far, here is where I am, after some fiddling and testing :

zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*'

Here is what I understand from it :

  • zstyle ':completion:*' means we are going to define a config value for completion
  • matcher-list is the config we update, here it defines how zsh match files/dir to suggest
  • 'm:{a-zA-Z}={A-Za-z}' 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*' are the arguments (values) to pass to the matcher-list config.
  • Here I have two arguments, separated by a space. It means zsh will first try to find files that match the first arg, and if it found nothing will try files that match the second arg

And here it becomes fuzzy :

  • I get that 'm:{a-zA-Z}={A-Za-z}' make the match case insensitive but I do not quite understand the syntax.
  • I also get that 'm:{a-zA-Z}={A-Za-z} l:|=* r:|=*' still is case insensitive, but also search for the match in the whole string, not just the start. But, I don't get the syntax either.

Can someone confirm my previous assertions, and correct them if needed, as well as detail the voodoo syntax of the arguments ?

Thanks

Edit : Oh, and sorry if the question is more fitted to superuser.com, I had a hard figuring which site was better suited for it.

like image 337
pixelastic Avatar asked Oct 26 '11 16:10

pixelastic


People also ask

What is zstyle in zsh?

zstyle is defined by the zsh/util module, this simply means that the code which defines how to parse, and "do" zstyle is defined in the zsh/zutil module. You could just as well forget this fact, i.e. bash doesn't require you to know that the code for the eval builtin is contained in the file eval.

How do you use zsh completion?

When you hit the tab key, the system will complete the path to the Documents folder. At this point, you can add a character or two to get to a unique completion, and hit the tab key again. In zsh you can also hit the tab key repeatedly to cycle through the suggested completions.

What does Compinit do in zsh?

The compinit file defines the following functions, which may also be called directly by the user. The first form tells the completion system to call the given function when completing for the contexts or commands whose names are given: this is like the #compdef tag.


1 Answers

Hi the zsh doc for this is at

http://zsh.sourceforge.net/Doc/Release/Completion-Widgets.html#Completion-Matching-Control

like image 68
zzapper Avatar answered Jan 05 '23 00:01

zzapper