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

How to strip off common prefix for array elements?



Consider the case:

cdpath=(~ ~/src ~/build/mips)
cd zshTAB -> gives me zsh-3.1.2 which is O.K., but I don't have any chance
to cd into build, because ~/src stays in the way.

The problem amounts to:

array of possile completions:
  ~/src/zsh-3.1.2 ~/build/mips/zsh-3.1.2
array of directories
  ~ ~/src ~/build/mips
Now I have to find the longest prefix from $cdpath elements so, that
remaining parts of completions are still uniq. 

the best way I can think of involves quite tedious loops over first and
second array. I had a vague hope, that it could be done with ZSH's magic
in parameter substitution. BTW somebody has an idea of extensions to allow
this be done (in general way)?

I am referring to Zoltan's cdmatch function. Currently it is nice 
one-liner - can it do the above and still remain small?

-------------------------------------------------------------------------
Andrej Borsenkow 		Fax:   +7 (095) 252 01 05
SNI ITS Moscow			Tel:   +7 (095) 252 13 88

NERV:  borsenkow.msk		E-Mail: borsenkow.msk@xxxxxx
-------------------------------------------------------------------------




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