Daniel Keast

Bash style tab completion for zsh

linux

In bash when using tab completion, the first press of the tab key lists out all of the completions:

$ touch forty-one forty-two one
$ ls <TAB>
forty-one  forty-two  one

Pressing tab again doesn’t do anything, it doesn’t know which of the presented options you are after. In the above example if you were to press f then press tab again it will autocomplete anything that is unambiguous. In this case:

$ ls forty-

Zsh is different though, when there are no unambiguous choices it behaves closer to CMD.COM for windows where each press of the tab cycles through available options:

$ ls forty-one<TAB>
$ ls forty-two<TAB>
$ ls one<TAB>

Pressing tab until the option I’m after is selected feels much slower to me than partially completing and asking for more input. It gets worse when there is a significant number of available options. To change zsh to behave more like Bash you can use the automenu option:

echo setopt noautomenu >> ~/.zshrc