I am trying to modify the behaviour of zsh completion and its menus. I'm stuck, and I've read so much documentation it's making my head spin.

The following is only an example; I'd prefer answers that aren't specific to cd.

I have zsh set up to only show the select menu if the completion is unambiguous (zstyle ':completion:*:*:*:*:*' menu select=2).

I have an alias alias cd='nocorrect cd'. When I do cd<TAB> (no space), zsh thinks it is unambiguous, and completes the alias. zsh thinks it is unambiguous--indeed, when I do cd<^D>, it only shows the one possible completion. In my mind, it should show other completion options like cdiff. Indeed, when I do cd<^Xn>, I see those other options. This is also the demonstrated behaviour in the ZSH User's Guide, section 6.5.2.

I sort of see what's going on. I have my completers set up as zstyle ':completion:*' completer _expand _expand_alias _complete _ignored _match _correct _approximate _prefix, so I can understand why it thinks expanding that alias is the first priority. I just can't figure out why it's the only option.

I would think it's something to do with tag-order, like in the second example in the user guide section 6.4.2. However, I don't have anything like that set up for this context (:completion::complete:-command-::), or anything else it might inherit from.

All of my completion-related settings are in this file on Github. Going up from there, you can see my zsh configuration in its entirety; however, I don't have anything set up for :completion: outside of this file, including in my .zshrc, so I doubt anything's overriding it.

So, can someone please explain to me what to do to get the behaviour I want?

FYI, I am using zsh with the Prezto framework, which I believe is irrelevant since the problem is entirely related to built-in zsh features and modules.

Some output:

cd<TAB>: just changes cd to nocorrect cd, no menu.

$ cd<^D>
-- alias --
nocorrect cd

$ cd<^Xn>
 -- external command --
cdbs-edit-patch    cd-fix-profile     cdiff                               
cd-create-profile  cd-iccdump                                           
 -- builtin command --
 -- shell function --
 -- alias --
 -- parameter --
CDPATH                                cdpath 

2 Answers 2


@Ilua's answer did not work, but it did give me some ideas of what to search for, and I solved the problem.

The style I needed was regular. From man zshcompsys:

   This style is used by the _expand_alias completer and bindable command. 
   If set to ‘true’ (the default), regular aliases will be expanded but only in command position. 
   If it is set to ‘false’, regular aliases will never be expanded.
   If it is set to ‘always’, regular aliases will be expanded even if not in command position. 

I used zstyle ':completion:*' regular 'false', and it works perfectly.


I think you are looking for the accept-exact style, which you want to set to false.

man zshcompsys

              This  is  tested for the default tag in addition to the tags valid for the current context.  If it is set to `true' and any of the trial matches is the same as the string on the command line, this match will immediately
              be accepted (even if it would otherwise be considered ambiguous).
  • Tried that out in various contexts, none worked. However, this answer gave me some ideas, and I've now figured it out! What I needed was regular. I'll add it as an actual answer.
    – skittleys
    Commented Jun 26, 2014 at 9:59

You must log in to answer this question.

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