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

Re: Good documentation about literal escape sequences in prompt?



Juhapekka Tolvanen wrote:
> 
> Well, let's see:
> 
> 1663 | p6 | juhtolv@heresy : /home/juhtolv
> % . /usr/share/zsh/functions/colors
> 1664 | p6 | juhtolv@heresy : /home/juhtolv
> % PS1="%{$fg_bold[red]%}$PS1%{$reset_color%}"
> [red]1665 | p6 | juhtolv@heresy : /home/juhtolv
> %
>
> And whole prompt is now cyan-colored.

I think that's a result of you using a slightly older version of Zsh
than the latest. The colors function has changed so that $fg_bold is an
associative array so for example $fg_bold[red] gives you the element
indexed by 'red'. Have a look in the colors function for a variable
definition for bold red and use that insead of $fg_bold[red] above or do
it directly as follows:

PS1="%{"$'\e[1;31m'"%}$PS1%{"$'\e[0m'"%}"

> When I find some escape sequences from /usr/share/zsh/functions/colors, how
> can I "convert" them so, that I can put them to my PS1 between %{...%} ?

You should be able to take my line above as an example of this.

> At least that question should be answered somewhere in docs. But it would be
> better to list all escape sequences in such format, that can be added to
> PS1 between %{...%}.

The list of escape sequences are not a feature of zsh but of your
terminal emulator. Try looking in the man pages for xterm. The colors
function merely defines zsh variables for command ANSI standard escape
sequences. Admittedly, the zsh docs could use a simple example of a
coloured prompt though.

Oliver Kiddle



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