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

Re: cdr completion



On Tue, 18 Feb 2014 15:27:55 +0100
Yuri D'Elia <wavexx@xxxxxxxxxx> wrote:
> With:
> 
> autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
> add-zsh-hook chpwd chpwd_recent_dirs
> zstyle ':chpwd:*' recent-dirs-default true
> zstyle ':completion:*' recent-dirs-insert always
> 
> the command:
> 
> cdr ~<TAB>
> 
> will still try to complete usernames (for the ~user home directory
> completion), which is something I'd like to avoid.
> 
> Is this avoidable?

Hmm... I think you can turn it off generally with something like

zstyle ':completion::complete:-tilde-::' tag-order named-directories

(allow named directories but not usernames), but so far as I know
there's no way of doing it just after cdr.  The problem is the context
here is a special one, "-tilde-", which replaces the normal command
context, so it no longer cares.  This happens early enough that none of
the special code to do with cdr is ever run.

I don't think it's that difficult to rejig the context in _tilde, which
isn't a particularly big function, so that it does care, by extracting
$words[1] from the command line and sticking it appropriately in the
context.  For example, replace the -tilde- with -tilde-$words[1].  I
haven't tried this --- and although it's useful it will break
compatibility with anyone trying to do this sort of thing for all
commands, so you might be better off just experimenting locally.

pws



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