Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: psvar + color
- X-seq: zsh-users 10978
- From: Peter Stephenson <pws@xxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: psvar + color
- Date: Tue, 14 Nov 2006 10:37:01 +0000
- In-reply-to: <ADC7CABE-A63E-42C1-A7F8-BC5E09367D79@xxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- References: <ADC7CABE-A63E-42C1-A7F8-BC5E09367D79@xxxxxxxxx>
Michael Hernandez wrote:
> The problem is that no matter what I do, I can't get the color to
> change by using %3v, for example, neither:
>
> p_apm="${fg_no_bold[%3v]}%(2v.*%2v.) "
>
> or
>
> p_apm="%{$fg_no_bold[%3v]}%}%(2v.*%2v.) "
>
> work properly.
Unfortunately the substitution is in the other order: the PROMPT_SUBST
replacement of variables comes before % substitution, so this scheme
wouldn't work.
> In the spirit of trying every possible thing I could think of I even
> tried p_apm="${fg_no_bold[$(print -P %3v)]}%(2v.*%2v.) "
This is close to working: the problem is the double quotes. This forces
the parameter expansion and command substitution to be performed
during the assignment. If you run 'print -r -- $p_apm' while changing
psvar you'll see it outputs the same fixed string. The %'s get
substituted later, but that's not good enough.
However, given that you have PROMPT_SUBST set you don't need to rely on
% substitution at all for the array subscript:
p_apm='%{${fg_no_bold[$psvar[3]]}%}%(2v.*%2v.) '
should do what you want.
--
Peter Stephenson <pws@xxxxxxx> Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK Tel: +44 (0)1223 692070
To access the latest news from CSR copy this link into a web browser: http://www.csr.com/email_sig.php
Messages sorted by:
Reverse Date,
Date,
Thread,
Author