Zsh Autocomplete – Case-Insensitive Mid-Word Completion

autocompletezsh

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)"

Best Answer

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.

Related Question