setopt magic_equal_subst
This works both with old-style and new-style completion, i.e. with or without compinit
.
Completion of file names after =
is an obscure and undocumented side effect of the magic_equal_subst
option. The documented effect of this option is to enable filename expansion after =
.
Most of the time, if you notice the effect of this option at all, it's a desirable effect, e.g.
somecommand --option=~/file
passes a path under your home directory to somecommand
, not a path in a directory called ~
. However, this also has the usually undesirable effect that an argument ==
triggers filename expansion:
somecommand foo==bar
passes foo=/bin/bar
if the command bar
is found in $PATH
at /bin/bar
. If you want to pass ==
literally to the command, at least one of the equal signs needs to be quoted, e.g.
somecommand foo=\=bar
somecommand foo\==bar
In the new-style completion system, this is handled inside _default
. If you want to get filename completion after =
without enabling magic_equal_subst
, you need to override or wrap around _default
to obtain the same effect. For example:
autoload +X -U _default
functions[_default]="setopt local_options magic_equal_subst; $functions[_default]"