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.

1 Answer 1


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_-}'
  • I put this into the .zprofile. I am not sure if this is the right place, but it works for me.
    – chiefenne
    Feb 9, 2020 at 14:20

You must log in to answer this question.

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