From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1352 invoked from network); 17 Sep 2006 17:59:43 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 17 Sep 2006 17:59:43 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 37369 invoked from network); 17 Sep 2006 17:59:37 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 17 Sep 2006 17:59:37 -0000 Received: (qmail 4106 invoked by alias); 17 Sep 2006 17:59:26 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10731 Received: (qmail 4097 invoked from network); 17 Sep 2006 17:59:25 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 17 Sep 2006 17:59:25 -0000 Received: (qmail 35821 invoked from network); 17 Sep 2006 17:59:25 -0000 Received: from vms042pub.verizon.net (206.46.252.42) by a.mx.sunsite.dk with SMTP; 17 Sep 2006 17:59:23 -0000 Received: from torch.brasslantern.com ([71.116.118.106]) by vms042.mailsrvcs.net (Sun Java System Messaging Server 6.2-4.02 (built Sep 9 2005)) with ESMTPA id <0J5Q00KWLXTHID20@vms042.mailsrvcs.net> for zsh-users@sunsite.dk; Sun, 17 Sep 2006 11:58:30 -0500 (CDT) Received: from torch.brasslantern.com (localhost.localdomain [127.0.0.1]) by torch.brasslantern.com (8.13.1/8.13.1) with ESMTP id k8HGwSjG020843 for ; Sun, 17 Sep 2006 09:58:29 -0700 Received: (from schaefer@localhost) by torch.brasslantern.com (8.13.1/8.13.1/Submit) id k8HGwSkk020842 for zsh-users@sunsite.dk; Sun, 17 Sep 2006 09:58:28 -0700 Date: Sun, 17 Sep 2006 09:58:28 -0700 From: Bart Schaefer Subject: Re: get output of a command in prompt In-reply-to: <20060917141420.GA5288@localhost.localdomain> To: zsh-users@sunsite.dk Message-id: <060917095828.ZM20839@torch.brasslantern.com> MIME-version: 1.0 X-Mailer: OpenZMail Classic (0.9.2 24April2005) Content-type: text/plain; charset=iso-8859-1 Content-transfer-encoding: quoted-printable References: <20060916184913.GA18417@localhost.localdomain> <20060916190154.GA24023@fsst.voodoo.lan> <20060917141420.GA5288@localhost.localdomain> Comments: In reply to "arno." "Re: get output of a command in prompt" (Sep 17, 4:14pm) On Sep 17, 4:14pm, arno. wrote: } } Le Saturday 16 September 2006, =E0 21:01:55PM +0200, Frank a =E9crit :=20 } > zsh% PS1=3D'$(printf "%s: %d" "This is a one" 1)-%% ' } > $(printf ": /home/hawk" "This is a one" 1)-% setopt promptsubst=20 } > This is a one: 1-% }=20 } Yes, I've tried things like that, but the problem is that command output= =20 } will be evaluated once, just when prompt is set up. Not true. The quoting is important: Note where single quotes (') have been used and where double quotes have. Compare: PS1=3D"$(printf '%s: %d' 'This is a one' 1)-%% " ;: This is the wrong way PS1=3D'$(printf "%s: %d" "This is a one" 1)-%% ' ;: This is the right way } It will not be evaluated each time prompt is displayed It will if the quoting is right and the promptsubst option has been set. Question for zsh-workers: Why is the prompt string being evaluated more than once on every zle reset? torch% PS1=3D'z is $((++z)) %# ' z is $((++z)) % setopt promptsubst z is 2 % echo I expect three I expect three z is 5 %=20 z is 8 % echo I guess I should expect eleven I guess I should expect eleven z is 11 %=20 This could be expensive for command substitutions in the prompt.