zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: beber mailing <beber.mailing@gmail.com>, zsh-users@sunsite.dk
Subject: Re: Misterous bug with %(# ...
Date: Mon, 7 Feb 2005 05:04:01 +0000	[thread overview]
Message-ID: <1050207050401.ZM1730@candle.brasslantern.com> (raw)
In-Reply-To: <4fb292fa0502061313586f5465@mail.gmail.com>

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 ^^ "


      reply	other threads:[~2005-02-07  6:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-02-06 21:13 beber mailing
2005-02-07  5:04 ` Bart Schaefer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1050207050401.ZM1730@candle.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=beber.mailing@gmail.com \
    --cc=zsh-users@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).