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

Re: Dynamic named directories and completion



 ❦ 22 février 2018 17:54 -0500, Scott Frazer <frazer.scott@xxxxxxxxx> :

> zsh_directory_name ()
> {
>     emulate -L zsh
>     setopt extendedglob
>     local -a seg;
>     seg=(${(s:/:)PWD%/*})
>     if [[ $1 = n ]]; then
>         typeset -ga reply
>         reply=( /${(j:/:)seg[1,(I)$2]} )
>     elif [[ $1 = c ]]; then
>         local expl
>         _wanted values expl 'parent dirs' compadd -S\] -a seg
>     else
>         return 1
>     fi
>     return 0
> }
>
> Suppose I am in directory /aaa/bbb/ccc/ddd/eee and want to go up to directory
> ccc and then down into another directory.  If I do:
>
> cd ~[c<TAB>
>
> it correctly completes to:
>
> cd ~[ccc]
>
> If I hit enter at this point I go to /aaa/bbb/ccc.  So far so good.  If I
> try to start completion, like so:
>
> cd ~[ccc]/<TAB>
>
> zsh doesn't give me options for directories under ccc, it thinks '/' is
> the command I'm trying to complete.  Is there a way to make this work?

I don't see anything wrong in your code and for me, it works as you
expect (zsh 5.4.2). Does "echo ~[ccc]" returns the right value?
-- 
This was the most unkindest cut of all.
		-- William Shakespeare, "Julius Caesar"



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