How to get zsh’s completion working in the middle of the filename

oh-my-zshzsh

This works

Normally, zsh's tab completion works well.

$ touch foo-1-bar foo-2-bar
$ touch f<Tab>
$ touch foo--bar
            ^ cursor here

Pressing Tab again brings up a menu from which I can select files.

$ touch foo--bar
foo-1-bar  foo-2-bar

This doesn't

However, this doesn't seem to work with strings where the beginning and end match. For example:

touch foo-bar foo-foo-bar
touch f<Tab>
touch foo-bar
         ^ cursor here. <tab> again.
touch foo-bar
              ^ cursor here.

No menu is brought up, and there is no opportunity to select foo-foo-bar. Is this expected behaviour or a bug? Is there a setting to make a menu appear in the latter scenario?

I'm using oh-my-zsh. I attempted removing all the completion-related lines from ~/.zshrc, but this made no difference.

Best Answer

As per the comments, I tried disabling oh-my-zsh, which fixed this problem. I then went through the oh-my-zsh source, selectively disabling modules.

I previously had CASE_SENSITIVE="true", but commenting out this line fixed it for me. Apparently it's a known bug.

To fix it, I could put the following line in ~/.zshrc after sourcing oh-my-zsh.

zstyle ':completion:*' matcher-list 'r:|=*' 'l:|=* r:|=*'
Related Question