21

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
    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 Jun 22 '16 at 16:59
42

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.

  • 1
    @Aaron: Glad to hear. Please consider to accept my answer then as explained in the SU tour. – mpy Jun 23 '16 at 16:19
  • 3
    So where do I put zstyle? – inherithandle Nov 22 '18 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 Oct 9 '19 at 3:26
  • 1
    @jdhao: Maybe you haven't initialized the completion system, use some other 3rd party settings (d'oh-my-zsh), etc... so, this is too complex to debug in the comments. Try to construct a minimal(!) case of your config files and write a separate question; something like "Why have my zstyle settings no effect?" – mpy Oct 9 '19 at 17:19
  • 8
    @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 Oct 9 '19 at 17:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.