6

Is it possible to tell zsh to not autocomplete certain commands when using TAB completion ?

EXAMPLE:

I type chm <tab> and zsh completion offers me two options:

chmem  chmod

I never use chmem. Instead of having two options, I would prefer to have chm automatically completed to chmod.

1 Answer 1

6

You can do:

zstyle ':completion:*:*:-command-:*:*' ignored-patterns 'chmem'

If you needed to do more than one ignored pattern, you would do it like this:

zstyle ':completion:*:*:-command-:*:*' ignored-patterns 'chmem|chcpu|chcon'
3
  • perfect. that works. thanks a lot Commented Jul 31, 2019 at 7:47
  • @Gilles - my list of ignored-patterns has gotten quite large. Is it possible to save the list in a file, and specify `zstyle ':completion:*:*:-command-:*:*' ignored-patterns /PATH/TO/FILE' ? Commented Sep 3, 2022 at 4:17
  • 1
    @MartinVegter Assuming the file contains one element per line: … "${(@f)$(</PATH/TO/FILE)}" Commented Sep 3, 2022 at 12:14

You must log in to answer this question.

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