Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Misterous bug with %(# ...
- X-seq: zsh-users 8471
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: beber mailing <beber.mailing@xxxxxxxxx>, zsh-users@xxxxxxxxxx
- Subject: Re: Misterous bug with %(# ...
- Date: Mon, 7 Feb 2005 05:04:01 +0000
- In-reply-to: <4fb292fa0502061313586f5465@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <4fb292fa0502061313586f5465@xxxxxxxxxxxxxx>
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 ^^ "
Messages sorted by:
Reverse Date,
Date,
Thread,
Author