Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Good documentation about literal escape sequences in prompt?
- X-seq: zsh-workers 10077
 
- From: Adam Spiers <adam@xxxxxxxxxx>
 
- To: zsh-workers@xxxxxxxxxxxxxx
 
- Subject: Re: Good documentation about literal escape sequences in prompt?
 
- Date: Sat, 11 Mar 2000 23:55:39 +0000
 
- In-reply-to: <Pine.LNX.4.10.10003120123170.22919-100000@xxxxxxxxxxxxxxx>; from juhtolv@xxxxxxxxx on Sun, Mar 12, 2000 at 01:41:37AM +0200
 
- Mail-followup-to: zsh-workers@xxxxxxxxxxxxxx
 
- Mailing-list: contact zsh-workers-help@xxxxxxxxxxxxxx; run by ezmlm
 
- References: <Pine.LNX.4.10.10003120123170.22919-100000@xxxxxxxxxxxxxxx>
 
- Reply-to: Adam Spiers <adam@xxxxxxxxxx>
 
Juhapekka Tolvanen (juhtolv@xxxxxxxxx) wrote:
> 
> %{...%}
>         Include a string as a literal escape sequence. The
>         string within the braces should not change the cursor
>         position. Brace pairs can nest.
> 
> Hey, come on! Do you really think that is enough? Why don't you provide some
> good examples? I know you can do it better!
> 
> For example this does not work:
> 
> PS1="%{\e[1;31m%}$PS1%{\e[1m%}"
That's because \e doesn't mean anything special within double-quotes;
it only gets interpreted as ASCII 27 when used inside $'' quotes, or
from the `print', `echo', or `bindkey' built-ins.  So what you want
is:
PS1=$'%{\e[1;31m%}'"$PS1"$'%{\e[1m%}'
I also made this mistake when first messing around with prompts, so it
looks like the relevant docs could indeed do with a bit of
improvement.  (Would do this myself, but still waiting for someone to
give me the go-ahead on sourceforge, or at least make up-to-date
snapshots available so that I can submit reliable patches.  Anyone
planning to release dev-20 before pws comes back?)
Adam
Messages sorted by:
Reverse Date,
Date,
Thread,
Author