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

Completion on cd


Exploring compctl, I wanted to do completion on cd. So I used the obvious

	compctl -g '*(-/)' cd

which gives me what I want... almost. If I enter:

	cd .<TAB>

I get no completions. OK, I thought, let's try a different approach.

	cdcomp() { setopt local_options null_glob; reply=($1*$2(-/)) }
	compctl -S / -q -K cdcomp cd

Almost right, but still not quite. If I enter:

	cd ^D

(^D does list-choices) I don't get slashes/at-signs behind the names
indicating whether it's a directory or a link. 

The problem is obviously that -g should be passed the current prefix and
suffix. Letting the completion mechanism select the possible entries just
isn't enough. Or would it be an idea to integrate globbing and completion
altogether, so that a * does not expand to all possible files/directories
but to all possible selections in that position. In general, these would
be files, but in other places hostnames, etc. This would be an easy way to
get, say, all hostnames, or perhaps all manpages starting with zsh...

Just an idea.

Wessel Dankers

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