From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17942 invoked from network); 6 Jan 2000 20:17:21 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 6 Jan 2000 20:17:21 -0000 Received: (qmail 29055 invoked by alias); 6 Jan 2000 20:17:01 -0000 Mailing-List: contact zsh-users-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 2844 Received: (qmail 29048 invoked from network); 6 Jan 2000 20:17:01 -0000 To: zsh-users@sunsite.auc.dk Subject: Re: Prompt expansion, multi-job for In-reply-to: "Andre Pang"'s message of "Thu, 06 Jan 2000 19:44:32 +1100." <20000106194432.A488@bozar.ihug.com.au> Date: Thu, 06 Jan 2000 20:18:56 +0000 From: Peter Stephenson Message-Id: Andre Pang wrote: > Hiya guys, > > I've got two completely separate questions about zsh. > > 1) Let's say I'm in the /usr/local/src path at the moment. Normally, if > you use the %~ prompt expansion, it will expand to /usr/local/src - no > surprises there. What I'd like to do is trim each path element to one > character unless it's the last path element, in which case it should be > displayed to a maximum of, say, 15 characters. eg, /usr/local/src should be > displayed as "/u/l/src", /usr/local/src/linux would be displayed as > "/u/l/s/linux", and /usr/local/src/linux-2.2.14+reiserfs+raid+ide might be > displayed as "/u/l/s/linux-2.2.14...". Is this possible with the current > prompt expansion codes, or will I have to write up a function to do it, if > it's possible to do at all? Without ~ backsubstitution (i.e. full paths with no insertion of ~'s), you can do it with the latest code as follows --- it won't work even with 3.1.6, because of the use of backreferences, as you've already discovered, so you'll need to get zsh-3.1.6-dev-14 from the development directory on the standard archives (if they're up to date). setopt extendedglob promptsubst PS1='${${PWD:h}//(#b)(\\/[^\\/])[^\\/]#/$match[1]}${${PWD:t}:+/}%15>...>${PWD:t}' I'll explain it if you like, but that would take a good deal longer than inventing it. I can't think of a way of getting the ~'s back just using parameter code, sorry (anyone else?). If you can live with just $HOME put back, you can replace PWD both times with ${PWD/$HOME/~}. -- Peter Stephenson