Bash PS1 prompt has no color in Alacritty and Contour, but it has color on Konsole

OS: Fedora 40 Workstation
Desktop: KDE Plasma 6.1.2 under Wayland

Issue: the bash prompt (PS1) has color in some terminals like Konsole, QTerminal, WezTerm…, etc., while it has no color on Alacritty and Contour

After talking to both alacritty and contour devs, it seems the issue is from bash
I have the bash-color-prompt package installed, and the TERM env var hasn’t been modified

Thank you

You’ll need to force it in your bashrc because.
from: Tree - rpms/shell-color-prompt - src.fedoraproject.org

Sourcing

Set prompt_color_force (before sourcing /etc/bashrc or bash-color-prompt.sh directly) to turn on bash-color-prompt unconditionally, otherwise by default it is only setup cautiously for a bash shell if $TERM ends in “color” and PS1 is the fedora or bash default.

For example:

if [ -t 0 ]; then
prompt_color_force=1
source /etc/profile.d/bash-color-prompt.sh
fi

can be added to ~/.bashrc to turn on bash-color-prompt “everywhere”.

1 Like

May I know why does this happen? (the behaviour on some terminals)

https://src.fedoraproject.org/rpms/shell-color-prompt/blob/rawhide/f/bash-color-prompt.sh#_64

The script looks if the TERM variable ends in color or if prompt_color_force is set to enable it.

You should be able to check this in one of the terminals by doing export TERM=xterm-256color and then executing bash again.

1 Like

Fixed it, many thanks!

1 Like