Reputation: 949
How can I make zsh auto-completion give me case-insensitive matches if I typed lowercase, but case-sensitive ones if I typed uppercase? For example, if I type "HOtab" it should offer HOME
and HOST
, but if I type "hotab" it should offer HOME
, HOST
, host
, hostinfo
, and hostname
.
The case-insensitive part is easy (matcher-list m:{a-zA-Z}={A-Za-z}
), and I found Have zsh return case-insensitive auto-complete matches, but prefer exact matches, but that's not quite what I want — if there are any exact lowercase matches, it will not offer the uppercase ones. I suspect the answer has to do with a left-anchored matcher, but I can't get it to work.
Upvotes: 2
Views: 1144
Reputation: 949
What I originally had in mind was that if the typed string contained any uppercase characters, it should be matched exactly. I still don't know how to do that. However, a slightly relaxed form works well enough for my purposes:
Framed like that, the answer is obvious: Remove my existing fully case-insensitive matcher-list
style (m:{a-zA-Z}={A-Za-z}
) and replace it with this:
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
Upvotes: 2