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\\] ' Thanks in advance
On 3/21/22, Frank Schwidom <schwidom@gmx.net> 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
On 2022-03-21 17:57:41, Mikael Magnusson wrote:
> On 3/21/22, Frank Schwidom <schwidom@gmx.net> 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.
On 3/21/22, Frank Schwidom <schwidom@gmx.net> wrote: > On 2022-03-21 17:57:41, Mikael Magnusson wrote: >> On 3/21/22, Frank Schwidom <schwidom@gmx.net> 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? Just enter a newline, eg PS1=' ' will give you a prompt with a newline in it. As for vi mode (I don't use it myself) you probably want to check out http://bewatermyfriend.org/media/vi-mode.zsh -- Mikael Magnusson
On Mon, Mar 21, 2022 at 10:59 AM Frank Schwidom <schwidom@gmx.net> wrote:
>
> How can I create a newline in PS1?
Just put an actual newline in it, zsh doesn't have a prompt "escape"
for newline. This can be accomplished by replacing $'\\n' in your
bash PS1 assignment with $'\n' in zsh.
PS1=$'%F{green}%n@%m %D{%Y-%m-%d %H:%M:%S}:\n%F{yellow}%~\n%F{magenta}%#%f '
On 2022-03-21 11:11:59, Bart Schaefer wrote:
> On Mon, Mar 21, 2022 at 10:59 AM Frank Schwidom <schwidom@gmx.net> wrote:
> >
> > How can I create a newline in PS1?
>
> Just put an actual newline in it, zsh doesn't have a prompt "escape"
> for newline. This can be accomplished by replacing $'\\n' in your
> bash PS1 assignment with $'\n' in zsh.
>
> PS1=$'%F{green}%n@%m %D{%Y-%m-%d %H:%M:%S}:\n%F{yellow}%~\n%F{magenta}%#%f '
>
Thanks.
On Mon, Mar 21, 2022 at 7:49 PM Mikael Magnusson <mikachu@gmail.com> wrote:
>
> As for vi mode (I don't use it myself) you probably want to check out
> http://bewatermyfriend.org/media/vi-mode.zsh
vi mode is as simple as `bindkey -v`. After that you might want to
define extra bindings but that's not different from defining bindings
for emacs mode.
Roman.
On Mon, Mar 21, 2022, at 1:47 PM, Frank Schwidom wrote:
> 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?
Just insert an actual newline.
PS1='single-quoted stuff'$'\n''more single-quoted stuff'
--
vq
On Mon, Mar 21, 2022 at 2:14 PM Roman Perepelitsa
<roman.perepelitsa@gmail.com> wrote:
>
> vi mode is as simple as `bindkey -v`.
That doesn't automatically include the (ins) indicator in the prompt,
though, which seemingly the \$ escape in bash does?
On 2022-03-21 14:43:50, Bart Schaefer wrote:
> On Mon, Mar 21, 2022 at 2:14 PM Roman Perepelitsa
> <roman.perepelitsa@gmail.com> wrote:
> >
> > vi mode is as simple as `bindkey -v`.
>
> That doesn't automatically include the (ins) indicator in the prompt,
> though, which seemingly the \$ escape in bash does?
>
No, this is the dollar sign. The (ins) and (cmd) flags are provided by the readline library.
The flag appears on the left side of the last line.
I cannot change it.
I guess zsh don't use readline. But it takes over the settings for the vi keybindings after I startet it from bash. I don't know the exact mechanism.
The readline config at the end of /etc/inputrc is:
set editing-mode vi
set completion-prefix-display-length 1
set show-mode-in-prompt on
The variable 'show-mode-in-prompt' is responsible for this flag.
Regards.