Zsh completion: menu and unambiguous prefix with a single tab

autocompletezsh

I'm in a folder where I have the following files:

aaa1  aaa2  aaa3  bbb1  bbb2  bbc1  bbc2

and I have typed cd a at the prompt. Currently,

  • pressing Tab completes to cd aaa
  • then another Tab brings up the menu (aaa1/ aaa2/ aaa3/)
  • and finally a third Tab completes to cd aaa1/
  • and subsequent presses cycle through the menu

I'd like to combine the first and second Tab, so that:

  • pressing Tab completes to cd aaa and brings up the menu
  • pressing another Tab completes to cd aaa1/
  • subsequent presses cycle through the menu as usual

OR

  • pressing Tab completes to cd aaa
  • pressing another Tab brings up the menu and completes to cd aaa1/
  • subsequent presses cycle through the menu as usual

Is there any combination of (un)setopt or zstyle that can achieve this?

Best Answer

Hmm, this method appears to get directly to selecting "aaa1" and being in a loop-on-the-menu-items mode:

exec zsh -f
zmodload zsh/complist
autoload -U compinit; compinit
bindkey "^I" menu-select
cd a

As does the menucomplete option:

exec zsh -f
autoload -U compinit; compinit
setopt menucomplete
cd a

There is an autolist option, but that only lists the options with input of cd aaa but not your desired cd a case. Hmm! How about this:

exec zsh -f
autoload -U compinit; compinit
setopt nolistambiguous
cd a

This completes to cd aaa and shows the "aaa*" directories.