Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: problem with bold prompt



Will Day wrote:
>My prompt is defined as:
>	export PS1="^[[1m${HOSTNAME}:^[[m%d) "
...
>It looks like zsh is counting the formatting characters as printable
>characters on the command-line.

This is exactly what it is doing; you have done nothing to tell it that
the escape sequences are not printable.  You can do that directly by
surrounding them in %{ and %}:

PS1='%{^[[1m%}${HOSTNAME}:%{^[[m%}%d) '

However, this still suffers one of the same basic problems as your
first attempt -- it will only work on a vt100-compatible terminal.  You
can solve this by using the sequences %B and %b to mark the bold text:

PS1='%B${HOSTNAME}:%b%d) '

This is more readable.  zsh will substitute the correct sequences for
whichever terminal you are using, and knows that they don't take up any
screen space (or, on a few odd terminals, that they do).

-zefram



Messages sorted by: Reverse Date, Date, Thread, Author