[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Color forgotten after newline in prompt when resizing window

From: ao2
Subject: Color forgotten after newline in prompt when resizing window
Date: Sat, 05 Oct 2019 17:52:58 +0200

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -fdebug-prefix-map=/build/bash-2bxm7h/bash-5.0=. 
-fstack-protector-strong -Wformat -Werror=format-security -Wall 
-Wno-parentheses -Wno-format-security
uname output: Linux jcn 5.2.0-3-amd64 #1 SMP Debian 5.2.17-1 (2019-09-26) 
x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 5.0
Patch Level: 3
Release Status: release


        I noticed that when there is a newline in the prompt bash "forgets"
        the ANSI color sequences when the window is resized. I am not sure if
        this is general for other kinds of ANSI escape codes.


        1. Set the prompt to something like:

             PS1='\[\033[36m\]cyan\ncyan\[\033[0m\]\$ '

           or equivalently to:

             PS1='\[$(tput setaf 6)\]cyan\ncyan\[$(tput sgr0)\]\$ '

        2. Resize the terminal window and see the second line of the prompt
           loosing the color.

I experience the problem with both gnome-terminal and xterm, so I don't think
it's the terminal emulator.

The issue can be worked around by specifying again the escape sequence after
the newline, e.g.:

     PS1='\[\033[36m\]cyan\n\[\033[36m\]cyan\[\033[0m\]\$ '

But that should not be needed, right?

The problem does not occur in zsh with neither gnome-terminal or xterm, using
the following equivalent prompt:

  PROMPT=$'%{\e[36m%}cyan\ncyan%{\e[0m%}\$ '


  PROMPT=$'%F{cyan}cyan\ncyan%f\$ '

So I thought it might be a bash specific issue.

Thank you,

Antonio Ospite

A: Because it messes up the order in which people normally read text.
   See http://en.wikipedia.org/wiki/Posting_style
Q: Why is top-posting such a bad thing?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]