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

Dynamic named directories and completion



I'm trying to use dynamic named directories and have subsequent completion work.

Here is my (perhaps naive) attempt:

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?

Thanks,
Scott




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