Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Reasoning: I have autocd enabled, yet I never use it because it makes tab-completion a huge pain, as every single command name on my system will be completed along with the filename completions.

Desired behavior: I want zsh to ONLY tab-complete commands if the completed string is not a prefix of any of the files in the current folder.

Example of desired behavior:

$ ls
... (other commands that start with fi)

I guess if this is not possible it would at least be nice to put directory completions before command completions.

share|improve this question

On bash if you do

. f<TAB>

then only file names will be listed. I don't know if zsh have the same behaviour. In general, bash autocompletes using only file names when you must input a path.

share|improve this answer

I have the following three lines in my ~/.zshrc file:

zle -C complete-files complete-word _generic
zstyle ':completion:complete-files:*' completer _files
bindkey "^F" complete-files

this binds Ctrl-f to file/folder completion, so if I know I definitely want to tab complete a filename then I use Ctrl-f instead of <tab>. Obviously you can use a different binding by changing ^F to something else. The result:

$ ls
$ f<tab>
$ f<Ctrl-f>
share|improve this answer
I was aware you can do this but this requires me to think what kind of tab completion I want before I tab-complete which is a big no-no for me. – user223814 Jun 13 '13 at 1:40

To get this exact behavior put this to your .zshrc:

compdef '_autocd || _command_names' -command-

I found the answer in this thread.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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