Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Probs with nested braces in PROMPT
- X-seq: zsh-users 3257
- From: Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxxxxxx (Zsh users list)
- Subject: Re: Probs with nested braces in PROMPT
- Date: Thu, 06 Jul 2000 11:12:12 +0100
- In-reply-to: "Your message of Thu, 06 Jul 2000 13:59:53 +0400." <000601bfe730$ee914ed0$21c9ca95@xxxxxxxxxxxxxx>
- Mailing-list: contact zsh-users-help@xxxxxxxxxxxxxx; run by ezmlm
Andrej wrote:
> >
> > PROMPT='%{^[[5;46m%}%m:%l %T %~${PROJECT:+
> > %{^[[31m[%}}$PROJECT${PROJECT:+]%{^[[30m%}}%#%{^[[0m%}'
> >
>
> What about
>
> PROMPT='%{^[[5;46m%}%m:%l %T %~${PROJECT:+
> %{^[[31m[%\}}$PROJECT${PROJECT:+]%{^[[30m%\}}%#%{^[[0m%}'
>
> (note, that `}' in %} are quoted). This seems to work. I suspect, why it
> happens, but I do not know code good enugh.
The problem was that ordinary ${...} doesn't know about %-substitution in
prompts, nor should it (that would be a horrendous complication involving
different levels of substitution). So it took the brace in `%}' as the
brace closing the substitution. Andrej's solution is the easiest way
round. Because of the way parameters are parsed, you could also do
esc1=$'%{\e[31m%}'
esc2=$'%{\e[30m%}'
PROMPT='%{^[[5;46m%}%m:%l %T %~${PROJECT:+
${esc1}[}$PROJECT${PROJECT:+]$esc2}%#%{^[[0m%}'
(replace line break by a space again) which you might consider neater.
You could even put the other escape sequences in that form: the $'\e'
saves you having literal ASCII escapes in your text.
--
Peter Stephenson <pws@xxxxxxxxxxxxxxxxxxxxxxxxx>
Cambridge Silicon Radio, Unit 300, Science Park, Milton Road,
Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070
Messages sorted by:
Reverse Date,
Date,
Thread,
Author