I have the following in my .zshrc for case-insensitive tab completion. I encountered a situation where the tab completion fails, and I can't figure out why.

autoload -U compinit && compinit

zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' '+l:|=* r:|=*'

$ ls
Elephant/ ElephantExample/

$ cd ex[TAB]  # completion doesn't do anything here
$ cd x[TAB]   # completion works as expected --> ElephantExample/
$ cd E[TAB]   # completion works as expected --> Elephant
$ cd e[TAB]   # completion works as expected --> Elephant

Can someone help explain this to me? Is this a bug with zsh?

EDIT: I'm using "zsh 5.0.7 (x86_64-apple-darwin13.4.0)"

  • try zsh -f then running run compinit, add the zstyle, then try.
    – llua
    Apr 22, 2015 at 1:01
  • @llua That will spawn a new subshell and not load any .zshrc correct? Just tried it and I get the same results.
    – Russell
    Apr 22, 2015 at 1:33
  • it spawns a new zsh process, not a subshell.
    – llua
    Apr 22, 2015 at 3:02
  • Completing x[TAB] to ElephantExample/ is not what I would expect and not what happens in any of my experiments. If you want anything to match at the start of the line, you need something like zstyle ':completion:*' matcher-list '' 'b:=* m:{[:lower:][:upper:]}={[:upper:][:lower:]}'
    – okapi
    Nov 11, 2019 at 11:34

1 Answer 1


Changing the style to:

 zstyle ':completion:*' matcher-list '' 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' \
  '+l:|?=** r:|?=**'

Would allow ex<tab> to expand to ElephantExample, but there may be undesired side effects.

  • 1
    Thank you, could you point out what possible side effects might arise? The docs weren't too helpful for me. EDIT: I see... x<tab> now expands to xElephant rather than ElephantExample
    – Russell
    Apr 22, 2015 at 16:58
  • The _approximate or _correct completers may be a better way of solving the problem, but anyway; it isn't a bug in zsh.
    – llua
    Apr 22, 2015 at 19:43
  • 1
    I found one undesirable side effect. Here is an example: cd ~/hel<tab> results in cd ~~/ when there is no matching directory.
    – aharris88
    Sep 22, 2016 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.