Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Directory completion acts as if CHASE_LINKS is set
On Thu, 05 Sep 2013 08:31:39 -0700
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> diff --git a/Completion/Zsh/Command/_cd b/Completion/Zsh/Command/_cd
> index 476947f..9c82a2f 100644
> --- a/Completion/Zsh/Command/_cd
> +++ b/Completion/Zsh/Command/_cd
> @@ -51,6 +51,14 @@ else
> _directory_stack && ret=0
> fi
>
> + if [[ $PREFIX = (|*/)..(|/*) ]]; then
> + local tmpprefix
> + # Use cd in a subshell to properly [not] resolve symlinks
> + tmpprefix=$(cd $PREFIX >&/dev/null && print $PWD) ||
> + tmpprefix=$(cd $PREFIX:h >&/dev/null && print $PWD/$PREFIX:t)
> + [[ -n $tmpprefix ]] && PREFIX=$tmpprefix
> + fi
> +
> if [[ $PREFIX != (\~|/|./|../)* ]]; then
> local tmpcdpath alt
You're probably going to be better off using ${PREFIX:a} rather than
cd. I also wonder if it would be better only to look at previous
directory components, i.e. always take the PREFIX up to the last "/"
(and require that there be one) rather than have two cases.
I doubt there's much you can do better if you're completing in the
middle of the word. If COMPLETEINWORD is not set, so you're sensitive
to $SUFFIX, you might use $PREFIX$SUFFIX, but apart from that $PREFIX
looks like the only interesting bit for path resolution. This is rather
specialised.
--
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/
Messages sorted by:
Reverse Date,
Date,
Thread,
Author