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 27590
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: Frank Schwidom <schwidom@xxxxxxx>
- Cc: zsh-users@xxxxxxx
- Subject: Re: Hi, can someone help me to convert my bash PS1 to zsh?
- Date: Mon, 21 Mar 2022 17:57:41 +0100
- Archived-at: <https://zsh.org/users/27590>
- In-reply-to: <20220321160650.GA1727@debian64>
- List-id: <zsh-users.zsh.org>
- References: <20220321160650.GA1727@debian64>
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