[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Forgets color when resizing with newline in prompt
From: |
ao2 |
Subject: |
Forgets color when resizing with newline in prompt |
Date: |
Sat, 05 Oct 2019 17:41:29 +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
Description:
I noticed that when there is a newline in the prompt bash "forgets"
about ANSI color sequences when the window is resized. I am not sure
f this is general for other kinds of ANSI escape codes.
Repeat-By:
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 with gnome-terminal or xterm,
with the following equivalent prompt:
PROMPT=$'%{\e[36m%}cyan\ncyan%{\e[0m%}\$ '
or
PROMPT=$'%F{cyan}cyan\ncyan%f\$ '
so I thought it might be a bash specific issue.
Thank you,
Antonio
--
Antonio Ospite
https://ao2.it
https://twitter.com/ao2it
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?
- Forgets color when resizing with newline in prompt,
ao2 <=