5

I don't like typing underscores, and would like to type a dash instead, and have zsh autocompletion treat it like it could be either a dash or an underscore.

Is this possible with built-in zsh capabilities, oh-my-zsh or something else? Would it be possible globally, and if not, would it be possible for a single autocompletion function?

Aside: I currently have a customized completion function for bashmarks that just translates underscores to dashes when providing possible completions, and would like to replace/improve it.

3

The zshcompsys man page has a similar example to get case insensitive completion

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

Changing it to make - and _ equivalent seems to do what you want

zstyle ':completion:*' matcher-list '' 'm:{-_}={_-}'

Or you could add it to the first example, and get case insensitive completion too

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

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.