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.