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

Re: cd ..<tab>?

On Feb 5,  6:19pm, Dennis Haney wrote:
} Bart Schaefer wrote:
} >>Is there a way to make this work properly with setopt GLOB_DOTS?
} >
} >Just make the style more specific:
} >
} >  zstyle ':completion:*:(cd|chdir|pushd|popd):*' special-dirs ..
} >
} How is that going to help me?

Apparently I misunderstood the question.  It'll help by making ".." not
be completed for commands other than "cd" et al., which was the only
way I could think of (at the time) that GLOB_DOTS could be involved.

} >You might also check the documentation for the ignore-parents style.
} >
} ignore-parent works the wrong way...


} It want to ignore '..' when it is a stupid choice.
} eg.
} mkdir Z
} cd Z/[tab]
} should NOT complete to 'cd Z/../'
} (unless CHASE_DOTS is on and 'cd Z/..' will be different from 'cd .')

This is a case where you need 'zstyle -e'.  You want the special-dirs
style to be non-empty only in certain circumstances.

This completes `..' only if the prefix is either empty, or has a leading
`.' and contains no slashes:

    zstyle -e ':completion:*' special-dirs \
        '[[ $PREFIX = (|.[^/]#) ]] && reply=(..)'

To find out that `Z/..' is not the same directory as `.' requires a bit
of extra work, which I don't have time to do just now, but you can see
how you'd just insert that into the conditions under which the reply
array is set by the style.

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

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