Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
How to strip off common prefix for array elements?
- X-seq: zsh-users 1329
- From: Andrej Borsenkow <borsenkow.msk@xxxxxx>
- To: Zsh users mailing list <zsh-users@xxxxxxxxxxxxxxx>
- Subject: How to strip off common prefix for array elements?
- Date: Thu, 19 Feb 1998 14:10:25 +0300 (MSK)
- Reply-to: borsenkow.msk@xxxxxx
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