You are not logged in.

#1 2023-07-01 21:02:44

mdcclxv
Member
Registered: 2022-04-26
Posts: 188

[SOLVED] Customize colors for ANSI color sequences

Hi there,

Is there any way I can customize the colors for the ANSI color escape codes? To be more clear, I want to change the color for the ANSI escape sequence bellow, also known as red.

\e[0;31m

Thanks in advance.

Last edited by mdcclxv (2023-07-01 22:29:32)

Offline

#2 2023-07-01 21:26:36

seth
Member
Registered: 2012-09-03
Posts: 57,935

Re: [SOLVED] Customize colors for ANSI color sequences

You can typically change the color theme of your TE (xterm, urxvt, alacritty, …) but that's part of the TEs config and there's no standard way.

Offline

#3 2023-07-01 21:42:38

mdcclxv
Member
Registered: 2022-04-26
Posts: 188

Re: [SOLVED] Customize colors for ANSI color sequences

Hmm, that means I'm going the wrong way. My actual problem is that git will show all modified files with a dark red that's hard to read. I'm using KDE's Konsole, which let's me edit the color theme. But git's red color stays the same no matter how I customize Konsole's theme, so I figured I might achieve that by going low level.

I did find some articles describing how to customize git's color output, but I want to replace that dark red for any app, not just for git.

I'm puzzled about how colors in terminal work. One thing I really don't grasp is since Konsole is the one doing the actual drawing of the text, how can an application (being git or any other) jump over Konsole's configuration?

Last edited by mdcclxv (2023-07-01 21:59:08)

Offline

#4 2023-07-01 22:00:43

seth
Member
Registered: 2012-09-03
Posts: 57,935

Re: [SOLVED] Customize colors for ANSI color sequences

You mean in "git status"?
Is the git color

print '\e[0;31mfoo\e[0m'

Otherwise inspect

    for fgbg in 38 48 ; do # Foreground / Background
        echo "\\e[${fgbg};5;<number>m"
        for color in {0..255} ; do # Colors
            # Display the color
            printf "\e[${fgbg};5;%sm  %3s  \e[0m" $color $color
            # Display 16 colors per lines
            if [ $((($color + 1) % 16)) == 0 ] ; then
                echo # New line
            fi
        done
        echo # New line
    done

for the concerned color (though it looks like \e[0;31m to me)

Offline

#5 2023-07-01 22:04:51

mdcclxv
Member
Registered: 2022-04-26
Posts: 188

Re: [SOLVED] Customize colors for ANSI color sequences

seth wrote:

You mean in "git status"?
Is the git color

print '\e[0;31mfoo\e[0m'

Yes, git status, and yes, that's the color.

Offline

#6 2023-07-01 22:13:48

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,322
Website

Re: [SOLVED] Customize colors for ANSI color sequences

mdcclxv wrote:

... which let's me edit the color theme

How exactly do you do this - and does this editting result in a change to the color of the "foo" test case seth provided above?  If it doesn't change the "foo" color, then it's not the correct color setting(s).

Last edited by Trilby (2023-07-01 22:14:33)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2023-07-01 22:28:18

mdcclxv
Member
Registered: 2022-04-26
Posts: 188

Re: [SOLVED] Customize colors for ANSI color sequences

Trilby wrote:
mdcclxv wrote:

... which let's me edit the color theme

How exactly do you do this - and does this editting result in a change to the color of the "foo" test case seth provided above?  If it doesn't change the "foo" color, then it's not the correct color setting(s).

Konsole supports Profiles and in each profile I can pick an Appearance Theme, which in itself it's editable.

But ... trying to answer to your second question I found out that Konsole has a bug: sometimes hitting Apply after editing the theme doesn't do the actual applying. That's was my actual issue, now git's output looks the way I want it.

Offline

#8 2023-07-01 22:29:00

mdcclxv
Member
Registered: 2022-04-26
Posts: 188

Re: [SOLVED] Customize colors for ANSI color sequences

Thank you both and apologies for wasting your time sad

Offline

Board footer

Powered by FluxBB