From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18749 invoked from network); 19 Feb 1998 11:24:23 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 19 Feb 1998 11:24:23 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id GAA08200; Thu, 19 Feb 1998 06:08:14 -0500 (EST) Resent-Date: Thu, 19 Feb 1998 06:08:00 -0500 (EST) Date: Thu, 19 Feb 1998 14:10:25 +0300 (MSK) From: Andrej Borsenkow X-Sender: bor@itsrm1 Reply-To: borsenkow.msk@sni.de To: Zsh users mailing list Subject: How to strip off common prefix for array elements? Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Resent-Message-ID: <"0SR6-.0.Z_1.GA1xq"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1329 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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@sni.de -------------------------------------------------------------------------