Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Expanding interactively aliases



Peter Stephenson wrote (on zsh-users):

> Quite possibly Sven has already added an option to the _expand 
> completer by now, otherwise I'll try and remember to look at that.

I had a quick look at _expand and, as I thought there is nothing to
explicitly expand aliases. I thought about adding it myself and had in
mind something along the lines of:

if zstyle -T ":completion:${curcontext}:" aliases; then
  (( CURRENT == 1 )) || exp=( "$exp[@]" "$aliases[$words[1]]" )
  exp=( "$exp[@]" "$galiases[$words[CURRENT]]" )
fi

This is fairly irrelevant and don't expect that to work because I've not
really tried it.

My real point is that the existing _expand appears to be expanding global
aliases already. I wouldn't have expected this because -U is used when
autoloading _expand. A quick check reveals that this is with the
substitute style and is due to the fact that the aliases are expanded
within eval.

I don't think it is ideal that autoload -U functions are subject to
aliases within eval and you could probably break a few bits of completion
with certain global aliases. Would it be easy to avoid this somehow? The
other solution would be a -U argument to eval which probably isn't a great
idea because eval currently takes no options.

And, BTW, alias has a -L option which you could have used in your
edit-alias function. Especially handy if you alias' name starts with '-'.

Oliver Kiddle



Messages sorted by: Reverse Date, Date, Thread, Author