How do I configure zsh for completion of partial words, but case-insensitive?

Viewed 607

Currently I have this in my ~/.zshrc:

zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'

AFAIU 'm:{a-z}={A-Za-z}' means that I will get case-insensitive tab completion, e.g. foo will tab-complete to Foobar (if that exists). And 'r:|[._-]=* r:|=*' 'l:|=* r:|=*' means that I will get matches for later parts of a word, e.g. bar will tab-complete to foobar (if that exists). But those partial matches are not case-insensitive. So for example bar will not tab-complete to FooBar (again, in case that exists).

Is there a way to get that working?

1 Answers

By default, the matchers in your matcher-list are tried one at a time, until one of them returns at least one match. By default, each matcher completely replaces the previous one. To instead make a matcher cumulative (that is, preserve the previous matcher and add to it), you need to prefix it with +:

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

More info:

Related