53

I switched to zsh completely on a previous arch install and I LOVED it mainly because arch is one of the distros that capitalizes your Documents, Downloads, Music and such directories in your ~ directory. Since I wasn't used to that and I use tab completion for almost everything in the terminal zsh was like heaven for me compared to bash.... I swear this feature used to be active automatically because I don't remember having to tweak anything to make it work that way. I probably figured it out on accident. xD But I would greatly like to have this feature restored on my new pc using zsh as my main shell, and if anyone knows how to do this I would really appreciate a reply. I tried activating every option in the completion configuration and that didn't seem to do the trick... so that brought me here.

PS: I used to be a lot more up to date with my Linux know-how, and my knowledge has grown stale... I'm trying to remedy that... (without the use of the shift key, as much as possible... haha)

1
  • 5
    Welcome to SU! To improve your style a comment: Your question is rather difficult to read, because there is a lot of unnecessary information. Please edit you question and try to concentrate on the relevant infos. Keep it short and simple ;).
    – mpy
    Commented Jun 22, 2016 at 16:59

1 Answer 1

100

TL;DR: This is possible if you put these lines in your zsh config file, usually ~/.zshrc:

autoload -Uz compinit && compinit
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'

A little bit more information:

This is possible when using the zsh completion system (started by autoload -Uz compinit && compinit) and is controlled by a zstyle:

zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}'

This tells zsh that small letters will match small and capital letters. (i.e. capital letters match only capital letters.)

If you want that capital letters also match small letters use instead:

zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}'

If you want case-insensitive matching only if there are no case-sensitive matches add '', e.g.

zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}'

See also the description of matcher-list in man zshcompsys.

10
  • 1
    @Aaron: Glad to hear. Please consider to accept my answer then as explained in the SU tour.
    – mpy
    Commented Jun 23, 2016 at 16:19
  • 4
    So where do I put zstyle? Commented Nov 22, 2018 at 14:44
  • 2
    I have added the above setting to my .zshrc and sourced it, but it does not seem to work. I have also tried to use the command in command line to no avail. Any ideas on how to make it work?
    – jdhao
    Commented Oct 9, 2019 at 3:26
  • 9
    @mpy Thanks for your kind reply. I have found that we need to add autoload -Uz compinit && compinit after the zstyle command to make the setting take effect. Maybe it is worthwhile to mention that in the answer for zsh novices like me...
    – jdhao
    Commented Oct 9, 2019 at 17:26
  • 2
    @jitbit: I added a "summary" with a snippet for easy copy&paste. I hope this will help to get this working faster.
    – mpy
    Commented Dec 26, 2021 at 11:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .