For some months now, I have had setopt completealiases in my .zshrc. I haven't the faintest idea why I added it - most other things have comments or can be understood from neighbouring settings. Because of this, I haven't had full tab completion for aliases for months, until I saw Gilles's answer here. I'm trying to understand why my idiotic past self would have added it without any explanation whatsoever1.

What's the intended use case for it? How is it commonly used?

1 My best guess is that I thought it enabled full completion for aliases and didn't bother to check the docs.

  • the documentation is pretty clear on what one might want to use that option for. What else would you expect from an answer here? Commented Dec 18, 2015 at 23:07
  • @StéphaneChazelas Why anyone would want to suppress completion for aliases, perhaps?
    – muru
    Commented Dec 19, 2015 at 1:32

1 Answer 1


By default, zsh expands aliases before performing completion. This is desirable most of the time. Occasionally, you may want to use different completions for a command when you use it through a certain alias. This is rare, and only tends to happen when the completion system isn't smart enough to determine the actual completions, and needs to get an extra hint. It can also happen if the alias changes the system state, e.g. alias e1='cd ~/myproject1 && $EDITOR' (for which you would want file name completions relative to ~/myproject1, whereas by default you'd get them relative to the current directory). Then you have two solutions:

  • Set complete_aliases, and define different completion functions for the aliases. If you do that, you need to set up completions for all the aliases you define, which makes it cumbersome.
  • Use a function instead of an alias for the rare cases where you want different completions. Zsh won't try to guess that given foo () { bar --wibble --wobble "$@"; }, completions for foo ought to be the same as after bar --wibble --wobble.

Given that aliases that require separate completions are rare, I don't really see a point for setopt complete_aliases — use a function instead.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .