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?
- X-seq: zsh-users 27591
- From: Frank Schwidom <schwidom@xxxxxxx>
- To: Mikael Magnusson <mikachu@xxxxxxxxx>
- Cc: Frank Schwidom <schwidom@xxxxxxx>, zsh-users@xxxxxxx
- Subject: Re: Hi, can someone help me to convert my bash PS1 to zsh?
- Date: Mon, 21 Mar 2022 18:47:41 +0100
- Archived-at: <https://zsh.org/users/27591>
- In-reply-to: <CAHYJk3S7XHDf98D3qCeC0bwmD3KqXqr52pX1xwm8Nnr=OFr1sg@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <20220321160650.GA1727@debian64> <CAHYJk3S7XHDf98D3qCeC0bwmD3KqXqr52pX1xwm8Nnr=OFr1sg@mail.gmail.com>
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:
~
(ins)$
This '(ins)' comes from readline in vi mode and tells me in which state I am.
How can I create a newline in PS1?
Regards.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author