14

I switched to zsh, but I dislike the completion. If I have 20 files, each with a shared prefix, on pressing tab, zsh will fully complete the first file, then continue going through the list with each press of tab. If I want one near the end, I would have to press tab many times.

In bash, this was simple - press tab and I would get the prefix. If I continued typing (and pressing tab), bash would complete as far as it could be certain of. I find this behavior to be much more intuitive but prefer the other features of zsh to bash.

Is there a way to get this style of completion? Google suggested setopt bash_autolist, but this had no effect for me (and no error message was printed upon starting my shell).

Thanks.

3 Answers 3

8

Try:

setopt autolist
unsetopt menucomplete
1
  • Works pretty well, not exactly the same but it's definitely something I can get used to. Thanks a lot!
    – nsm
    Jun 2, 2010 at 23:39
16

What you want is probably this:

setopt noautomenu
1
  • 5
    (10 years later) The accepted answer had no (apparent) effect for me. This was exactly what I wanted and what is seems like the OP was asking for.
    – Jer
    Feb 10, 2020 at 20:44
1

There's another option if you use the "menu select" option in .zshrc like this:

autoload -U compinit
compinit
zstyle ':completion:*:*:*:*:*' menu select

You will be able to navigate through the result with arrow keys. Let's take your example with "20 files with a shared prefix":

  • when first hitting [TAB], zsh will complete the more it can and then display a list of possibilities
  • then you can either complete like you would have in bash (type an extra character, goto 0)
  • or re-type [TAB] and then you will see the possible choices highlighted in the menu below your shell prompt ; bonus, you can navigate in the possibilities with your arrow keys

In the end to reach the last possibility:

  • with Bash, at best, you hit [TAB] then an extra char then [TAB] again (maybe more)
  • with Zsh, you hit [TAB] then [TAB] again (to enter the menu), then "<-" (left arrow key) to reach the last elements

Both are 3 key strokes in this very case. The rest is mostly a matter of taste.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.