Search code examples
zshoh-my-zsh

Have zsh return case-insensitive auto-complete matches, but prefer exact matches


I am using zsh with oh-my-zsh's rc file and there is some behavior I find particularly annoying. By default, oh-my-zsh is configured to return case-insensitive matches when auto-completing. This behavior is sometimes good, but other times it really sucks. Is there a way I can configure zsh to only use case-insenstive matching when there are no case-sensitive matches?

For instance, this case would use case-sensitive matching:

> ls
LICENSE.txt    lib/
> emacs l <-- should autocomplete to lib/

In this case, case-insensitive auto-completion would happen:

> ls
README    lib/
> emacs r <-- should autocomplete to README

Thanks!


Solution

  • Just uncomment the following line in ~/.zshrc:

    # Uncomment the following line to use case-sensitive completion.
    # CASE_SENSITIVE="true"
    

    It worked for me