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

Re: Completion for cd



On Mar 15,  8:22am, Jesper Nygards wrote:
}
} Thanks to your help, I managed to find a working solution, changing the
} critical lines to this:
} zstyle ':completion:*:complete:cd:*:*' tag-order local-directories
} directories -
} zstyle ':completion:*:withpath:cd:*:*' tag-order path-directories
} 
} In other words,  I have added 'directories' to the first line.
} 
} However, I still don't fully understand what is going on.

I believe your style settings are wrong.  You have:

zstyle ':completion:*:*:cd:*:*' completer _expand _complete \
    _complete:withpath _prefix _approximate _ignored
zstyle ':completion:*:withpath:cd:*:*' tag-order path-directories

But _complete:withpath sets the context to "completewithpath" not
to "withpath" so the path-directories tag-order will never match.
(This is why the example uses _complete:-foo so that the context
is complete-foo with the hyphen.)

In light of that --

>> I then go to '/tmp/zaa' and write 'cd ../z<tab>'.

"../z" is not a prefix of a local directory, so the local-directories
tag finds nothing.  (Anything starting with "/" or "../" is treated
as a non-local path.)

So it falls on through to _approximate.

When you add back "directories", _complete finds candidates in "../"
and ignore-parents kicks in.



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