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

compctl for cd

I wonder if anyone could help me - I'm having a bit of trouble with 
completion for cd.

I am trying to get it to work in the same way as tcsh (which I am 
currently converting from) but have come across a couple problems.

  Under tcsh, I used: complete cd 'n/*/d/'
  I'm using zsh 3.0.1 

Under tcsh, if I type cd [tab], It lists all directories except those
starting with a dot but is still happy if I type cd .[tab] to complete
directories starting with a dot and to list them. 

I tried to achieve this but the nearest I got was:
compctl -g '*(-/)' -x 'S[.]' -g '*(D,-/)' -- cd mkdir rmdir
This only matches with dot directories if the current word begins with a 
dot so for example, it is useless with bin/.something. I can't find a way of
matching this properly (as */.[^/] if you understand that).

As I experimented, I noticed a problem with the first expression in the 
completion: if from my home directory I did:

cd b[tab]    # No problem, expands to bin/
cd bin/[tab] # Now, all the files in bin aswell as directories are listed

If you use:
compctl -g '(*/)##' cd
then it will list all directories recursively with their names relative 
to the current which is no use.

Can anyone think of a solution (preferably without resorting to the use 
of functions)?

What would be nice would be if there was an option similar to -g but 
which took all directories up to the last slash in the current word 
and performed the glob as if that was the current directory.

While I'm e-mailing this list, I'll also point out in reference to the 
tilde expansion message recently sent by Wez that the manual contains a 
similar completion:

compctl -Tx 'C[0,*/*]' -f - 's[~]' -k friends -S/

This applies the expansion across the line and not just to the command and 
seems to work better.


Oliver Kiddle

/  \|.   _ _  |_/. _| _|| _     E-mail: opk101@xxxxxxxxxxxxx
\__/||\/(-|   | \|(_|(_||(-        Web: http://www.york.ac.uk/~opk101/

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