zshzsh-completion

Show completion menu instead of auto-selecting first match


Suppose there are executable commands named a, ab, ac, ad in my path.

If I type a [tab] at the zsh prompt, zsh simply adds a space after the a. Well, that's not wrong, because a is an existing command. But I want it to display all possible options in the auto-completion menu instead, so: a, ab, ac, ad.

For cases where the input before the [tab] doesn't correspond to a complete command, auto-completion works as intended.


Solution

  • By default, zsh's completion system is set to accept-exact, you can set this to false:

    0. Optional step: Make sure completion system is initialized:

    autoload -Uz compinit
    compinit
    
    1. Set this to false:
    zstyle ':completion:*' accept-exact false
    

    After restarting your shell, it should give you all command options.