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 2022-03-21 17:57:41, Mikael Magnusson wrote:
> 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

I want to create a multiline prompt. I am missing the code for carriage return or newline.

In bash my Prompt looks like:

user@computer 2022-03-21 18:43:18:

This '(ins)' comes from readline in vi mode and tells me in which state I am.

How can I create a newline in PS1?


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