Re: Multi-line PS1 color disappearance problem

2023-12-29 Thread Miro Palmu via Bug reports for the GNU Bourne Again SHell

On 12/26/23 21:47, Chet Ramey wrote:

On 12/22/23 2:25 AM, em...@miropalmu.cc wrote:


But I did not know that '\e' is valid
ANSI escape sequence prefix.


It's not in the ISO C definition of a character constant or string
literal. It's a common extension that bash and other shells implement --
common enough that it's in the POSIX specification of $'...' quoting, which
will be in the next version of the standard.

https://www.austingroupbugs.net/view.php?id=249



On 12/22/2023 07:21, Greg Wooledge wrote:
> It's not ANSI.  It's bash.  Specifically, bash allows \e as a synonym
> for \033 when expanding PS1, and inside $'...' quotes, and in readline
> key sequence definitions, and in arguments to echo with the -e option.
> It also allows \e in the printf format argument, though I don't see
> this mentioned in the documentation.

Thank you both for the additional information.

--
Miro Palmu




Re: Multi-line PS1 color disappearance problem

2023-12-26 Thread Chet Ramey

On 12/22/23 2:25 AM, em...@miropalmu.cc wrote:



But I did not know that '\e' is valid
ANSI escape sequence prefix.


It's not in the ISO C definition of a character constant or string
literal. It's a common extension that bash and other shells implement --
common enough that it's in the POSIX specification of $'...' quoting, which
will be in the next version of the standard.

https://www.austingroupbugs.net/view.php?id=249

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: Multi-line PS1 color disappearance problem

2023-12-22 Thread Greg Wooledge
On Fri, Dec 22, 2023 at 07:25:30AM +, email--- via Bug reports for the GNU 
Bourne Again SHell wrote:
> On 2023-12-21 17:32, Alex Ratchev wrote:
> 
> > do u really PS1=\[\033 etc ?
> > 
> > try PS1='\[\e...'
> > 
> > in ' quotes
> 
> I forgot quotes from the email. But I did not know that '\e' is valid
> ANSI escape sequence prefix.

It's not ANSI.  It's bash.  Specifically, bash allows \e as a synonym
for \033 when expanding PS1, and inside $'...' quotes, and in readline
key sequence definitions, and in arguments to echo with the -e option.
It also allows \e in the printf format argument, though I don't see
this mentioned in the documentation.



Re: Multi-line PS1 color disappearance problem

2023-12-21 Thread email--- via Bug reports for the GNU Bourne Again SHell

On 2023-12-21 17:55, Chet Ramey wrote:

Think of the portion of a multi-line prompt before the final newline as 
a

static string that will not affect the display of the last line.


Yep. Makes sense.

On 2023-12-21 17:32, Alex Ratchev wrote:


do u really PS1=\[\033 etc ?

try PS1='\[\e...'

in ' quotes


I forgot quotes from the email. But I did not know that '\e' is valid
ANSI escape sequence prefix. I just picked the one that looked most sane
to me from here (which does not contain '\e'):

https://gist.github.com/fnky/458719343aabd01cfb17a3a4f7296797



Re: Multi-line PS1 color disappearance problem

2023-12-21 Thread Chet Ramey
On 12/21/23 11:40 AM, email--- via Bug reports for the GNU Bourne Again 
SHell wrote:



Bash Version: 5.2
Patch Level: 21
Release Status: release

Description:
     When PS1 contains line break and it sets color with ansi escape code 
before the line break,
     then in any terminal emulator after zoom out or in, the color of the 
second line disappears.

     The color is also missing terminal is opened.


The way prompting works is that readline prints the entire prompt string
once, but only (potentially) reprints the last line of a multi-line prompt.
That's the only line that will change due to input or redisplay; there's no
reason to move up and reprint the rest. You can force readline to redisplay
the entire prompt by using ^L (clear-screen), but that has obvious side
effects.

Think of the portion of a multi-line prompt before the final newline as a
static string that will not affect the display of the last line.

If you want colors in both portions, specify them separately.

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: Multi-line PS1 color disappearance problem

2023-12-21 Thread alex xmb sw ratchev
On Thu, Dec 21, 2023, 18:26 email--- via Bug reports for the GNU Bourne
Again SHell  wrote:

> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt
> -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat
> -Werror=format-security -fstack-clash-protection -fcf-protection
> -g -ffile-prefix-map=/build/bash/src=/usr/src/debug/bash -flto=auto
> -DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin'
> -DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc'
> -DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
> uname output: Linux fuksilappari 6.6.7-arch1-1 #1 SMP PREEMPT_DYNAMIC
> Thu, 14 Dec 2023 03:45:42 + x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
>
> Bash Version: 5.2
> Patch Level: 21
> Release Status: release
>
> Description:
>  When PS1 contains line break and it sets color with ansi escape code
> before the line break,
>  then in any terminal emulator after zoom out or in, the color of the
> second line disappears.
>  The color is also missing terminal is opened.
>
> Repeat-By:
>  PS1=\[\033[31m\]first line\nsecond line\[\033[0m\]
>  zoom in or out and observe disappearing color.
>
>  Compare to this which does not have the same problem due setting
> color again after the linebreak:
>  PS1=\[\033[31m\]first line\n\[\033[31m\]second line\[\033[0m\]
>

do u really PS1=\[\033 etc ?

try PS1='\[\e...'

in ' quotes

>


Multi-line PS1 color disappearance problem

2023-12-21 Thread email--- via Bug reports for the GNU Bourne Again SHell

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt 
-fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat 
-Werror=format-security -fstack-clash-protection -fcf-protection 
-g -ffile-prefix-map=/build/bash/src=/usr/src/debug/bash -flto=auto 
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin' 
-DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc' 
-DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
uname output: Linux fuksilappari 6.6.7-arch1-1 #1 SMP PREEMPT_DYNAMIC 
Thu, 14 Dec 2023 03:45:42 + x86_64 GNU/Linux

Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.2
Patch Level: 21
Release Status: release

Description:
When PS1 contains line break and it sets color with ansi escape code 
before the line break,
then in any terminal emulator after zoom out or in, the color of the 
second line disappears.

The color is also missing terminal is opened.

Repeat-By:
PS1=\[\033[31m\]first line\nsecond line\[\033[0m\]
zoom in or out and observe disappearing color.

Compare to this which does not have the same problem due setting 
color again after the linebreak:

PS1=\[\033[31m\]first line\n\[\033[31m\]second line\[\033[0m\]