How can I make zsh tab completion fix capitalization errors for directories and files?
Solution 1:
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
.