From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8948 invoked from network); 7 Feb 2005 06:16:22 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 7 Feb 2005 06:16:22 -0000 Received: (qmail 51180 invoked from network); 7 Feb 2005 06:16:16 -0000 Received: from unknown (HELO sunsite.dk) (130.225.247.90) by a.mx.sunsite.dk with SMTP; 7 Feb 2005 06:16:16 -0000 Received: (qmail 29653 invoked by alias); 7 Feb 2005 05:04:33 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8471 Received: (qmail 29639 invoked from network); 7 Feb 2005 05:04:32 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 7 Feb 2005 05:04:32 -0000 Received: (qmail 28161 invoked from network); 7 Feb 2005 05:04:16 -0000 Received: from out001pub.verizon.net (HELO out001.verizon.net) (206.46.170.140) by a.mx.sunsite.dk with SMTP; 7 Feb 2005 05:04:12 -0000 Received: from candle.brasslantern.com ([4.11.10.129]) by out001.verizon.net (InterMail vM.5.01.06.06 201-253-122-130-106-20030910) with ESMTP id <20050207050407.HLEA29541.out001.verizon.net@candle.brasslantern.com>; Sun, 6 Feb 2005 23:04:07 -0600 Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j17542EF001732; Sun, 6 Feb 2005 21:04:02 -0800 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j17541rO001731; Sun, 6 Feb 2005 21:04:01 -0800 From: Bart Schaefer Message-Id: <1050207050401.ZM1730@candle.brasslantern.com> Date: Mon, 7 Feb 2005 05:04:01 +0000 In-Reply-To: <4fb292fa0502061313586f5465@mail.gmail.com> Comments: In reply to beber mailing "Misterous bug with %(# ..." (Feb 6, 10:13pm) References: <4fb292fa0502061313586f5465@mail.gmail.com> X-Mailer: Z-Mail (5.0.0 30July97) To: beber mailing , zsh-users@sunsite.dk Subject: Re: Misterous bug with %(# ... MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Authentication-Info: Submitted using SMTP AUTH at out001.verizon.net from [4.11.10.129] at Sun, 6 Feb 2005 23:04:03 -0600 X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Feb 6, 10:13pm, beber mailing wrote: } } host_color=%(#.magenta.green) } host="%{$fg[$host_color]%}(%m)" } warninfo="%{$fg[$host_color]%}^^ ROOT ^^ " [...] } PS1="$jobs$warninfo$cpath$end $ret%# " } RPS1="$host $date$end" } } But the color for $host is always black, I don't know why. You have a problem with understanding the order of evaluation. %(#.true.false) is evaluated only when a prompt is printed, not at other times when variables are interpolated. What's happening is that the value of $fg[%(#.magenta.green)] is looked up at the time of the assignment to "host" -- and there is no key "%(#.magenta.green)" in the $fg associative array, so that returns nothing. By the time the various remaining %-expandos in the PS1 and RPS1 strings are interpreted, it's too late. What you need is: host_color="%(#.$fg[magenta].$fg[green])" host="%{$host_color%}(%m)" warninfo="%{$host_color%}^^ ROOT ^^ "