* cdr completion
@ 2014-02-18 14:27 Yuri D'Elia
2014-02-18 15:45 ` Peter Stephenson
0 siblings, 1 reply; 6+ messages in thread
From: Yuri D'Elia @ 2014-02-18 14:27 UTC (permalink / raw)
To: zsh-users
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?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: cdr completion
2014-02-18 14:27 cdr completion Yuri D'Elia
@ 2014-02-18 15:45 ` Peter Stephenson
2014-02-18 16:34 ` Yuri D'Elia
0 siblings, 1 reply; 6+ messages in thread
From: Peter Stephenson @ 2014-02-18 15:45 UTC (permalink / raw)
To: zsh-users
On Tue, 18 Feb 2014 15:27:55 +0100
Yuri D'Elia <wavexx@thregr.org> 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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: cdr completion
2014-02-18 15:45 ` Peter Stephenson
@ 2014-02-18 16:34 ` Yuri D'Elia
2014-02-18 16:56 ` Peter Stephenson
0 siblings, 1 reply; 6+ messages in thread
From: Yuri D'Elia @ 2014-02-18 16:34 UTC (permalink / raw)
To: zsh-users
On 02/18/2014 04:45 PM, Peter Stephenson wrote:
>> 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.
This would be fine for me. The ~username expansion is something I never
ever used.
However the above style doesn't really disable the expansion for me.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: cdr completion
2014-02-18 16:34 ` Yuri D'Elia
@ 2014-02-18 16:56 ` Peter Stephenson
2014-02-18 17:48 ` Yuri D'Elia
2014-02-18 20:02 ` Yuri D'Elia
0 siblings, 2 replies; 6+ messages in thread
From: Peter Stephenson @ 2014-02-18 16:56 UTC (permalink / raw)
To: zsh-users
On Tue, 18 Feb 2014 17:34:59 +0100
Yuri D'Elia <wavexx@thregr.org> wrote:
> On 02/18/2014 04:45 PM, Peter Stephenson wrote:
> >> 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
>
> This would be fine for me. The ~username expansion is something I never
> ever used.
>
> However the above style doesn't really disable the expansion for me.
Sorry, try:
zstyle ':completion::complete:-tilde-::' tag-order - named-directories
or perhaps better
zstyle ':completion::complete:-tilde-::' tag-order - \
'named-directories directory-stack'
instead. For some reason the other form was working for me, so I failed
to go and read the documentation, which is lethal. The "-" is needed
to tell it that you *only* want the tags you specify completed.
pws
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: cdr completion
2014-02-18 16:56 ` Peter Stephenson
@ 2014-02-18 17:48 ` Yuri D'Elia
2014-02-18 20:02 ` Yuri D'Elia
1 sibling, 0 replies; 6+ messages in thread
From: Yuri D'Elia @ 2014-02-18 17:48 UTC (permalink / raw)
To: zsh-users
On 02/18/2014 05:56 PM, Peter Stephenson wrote:
> zstyle ':completion::complete:-tilde-::' tag-order - \
> 'named-directories directory-stack'
>
> instead. For some reason the other form was working for me, so I failed
> to go and read the documentation, which is lethal. The "-" is needed
> to tell it that you *only* want the tags you specify completed.
Ah yes, thanks for pointing that out. Now it works as planned.
And, for maximum comfort:
zstyle ':completion::complete:-tilde-::' tag-order - \
'named-directories:-home named-directories directory-stack'
zstyle ':completion::complete:-tilde-:*:named-directories-home' fake '/'
will complete ~ to ~/ if there is nothing else.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: cdr completion
2014-02-18 16:56 ` Peter Stephenson
2014-02-18 17:48 ` Yuri D'Elia
@ 2014-02-18 20:02 ` Yuri D'Elia
1 sibling, 0 replies; 6+ messages in thread
From: Yuri D'Elia @ 2014-02-18 20:02 UTC (permalink / raw)
To: zsh-users
On 02/18/2014 05:56 PM, Peter Stephenson wrote:
> zstyle ':completion::complete:-tilde-::' tag-order - named-directories
>
> or perhaps better
>
> zstyle ':completion::complete:-tilde-::' tag-order - \
> 'named-directories directory-stack'
mmmh.
zstyle ':completion:*:-tilde-:*' users ''
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2014-02-18 20:02 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-18 14:27 cdr completion Yuri D'Elia
2014-02-18 15:45 ` Peter Stephenson
2014-02-18 16:34 ` Yuri D'Elia
2014-02-18 16:56 ` Peter Stephenson
2014-02-18 17:48 ` Yuri D'Elia
2014-02-18 20:02 ` Yuri D'Elia
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).