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

Re: Hi, can someone help me to convert my bash PS1 to zsh?



On 3/21/22, Frank Schwidom <schwidom@xxxxxxx> wrote:
> And here it is:
>
> (ins)$ echo "$PS1"
> \[\]\u@\h \D{%Y-%m-%d %H:%M:%S}:\n\[\]\w\n\[\]\$\[\]
>
> (ins)$ set | grep '^PS1='
> PS1=$'\\[\E[32m\\]\\u@\\h \\D{%Y-%m-%d
> %H:%M:%S}:\\n\\[\E[33m\\]\\w\\n\\[\E[35m\\]\\$\\[\E[0m\\] '

The manpage lists all the codes for zsh, which start with %. If you
don't want to scroll down that much, you can also interactively type
PS1=% and then hit tab for an abbreviated list. (the format inside
%D{} is likely to be the exact same)

Separately from that, you'll want to remove any \e[32m stuff and
instead use %F{red} to start a color and %f to end (eg the 0m). If you
use hardcoded escape sequences, you have to write %{ %} around them,
or your cursor will end up in funny places, but there is no reason to
do so for the codes you use.

For example you might have, PS1='%F{blue}%n@%m %D{%Y-%m}%f' etc. (I
don't know what the remaining bash codes correspond to).

-- 
Mikael Magnusson




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