Let's say I have the following files in the directory:

  • abc123ABC
  • abc123QWE
  • abc456

Now suppose I type a and hit TAB.

In bash the completion as it usually works would just complete abc and stop with me having to "resolve" the next symbol. so if I type 1 I'll be able to complete to abc123 with the next TAB.

In zsh, at least in the way it is configured on my machine it will complete the whole variant, the first one in this case: abc123ABC and present me with the menu to change that to other variants.

This is usually good, but it turns out ugly and completely useless when there are a lot of files to complete. usually in such cases it would be easy/trivial to narrow down the choices by typing a couple of characters after the 'common' part.

I like the menu part but I'd really prefer for it to only complete the 'common' parts and complete in full on second TAB or using menu, but still w/o losing the ability to manually narrow the choices by typing a character or two.

Is there anything like that supported in zsh?

2 Answers 2


You should explore the compinstall completion customization program.

autoload -Uz compinstall && compinstall

In the version that I am using (zsh 4.3.10), the option for inserting unambiguous prefixes is inside the following menu

  • 3 “Styles for changing the way completions are displayed and inserted.”
    • 2 “Change how completions are inserted: …”
      • 1 “… insert any unambiguous prefix rather than [going] straight to menu completion”
        • y

Once saved, this results in the following command saved to the completion customization file (usually .zshrc):

zstyle ':completion:*' insert-unambiguous true
  • 3 “Styles for changing the way completions are displayed and inserted.”
    • 3 “Configure … completion lists, selection of items, …”
      • 2 “Use cursor keys to select completions from completion lists.”
        • 1
        • Return

Once saved, this results in the following customization:

zstyle ':completion:*' menu select=1
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s

You might like to customize the first one by adding interactive:

zstyle ':completion:*' menu select=1 interactive
  • thanks, we are almost there... ;) at first it didn't work, then I tried to disable all my other completion settings and it did work. so I started to bisect the config and at the end the conflicting option is zstyle ':completion:*:*:*:*:*' menu yes select The problem is I really like it ;) the menu is good, I like to choose the options with the arrow keys. is it possible for them to work together? Jul 7, 2010 at 14:25
  • oh, btw, if you need, my zsh config is at github.com/astrails/dotzsh Jul 7, 2010 at 14:26

Another solution is to add this line in your .zshrc:

[[ -e ~/.profile ]] && emulate sh -c 'source ~/.profile'

This will behave exactly as you said (common characters are added, then a new tab triggers the zsh list menu).

Note: if it does not work, ensure you didn't set the AUTO_LIST option:

# if the completion is ambiguous, immediately display the list of possible completions
# setopt AUTO_LIST # <- don't set this one

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.