0

I've been learning how to customize my prompt with colors. I understand that you can define red text with

\e[0;31m

and define an RGB color (in the following example, R=255, G=95, B=255) as

\e[38;2;255;95;255m

To make the first command bold, you can just change the 0 to a 1:

\e[1;31m

But how do you make the RGB command bold?

1

You can combine the two:

printf %b == '\e[1m' '\e[38;2;255;95;255m' FOO '\e[m' == '\n'

The first sets the bold attribute, the second sets the color.

You should check whether your terminal emulator really supports bold characters (and isn't emulating them with color / reverse video or just ignoring them in some modes, as does eg. the linux vt) and enable it if it's disabled. Most terminal emulators working under X11 need no extra configuration for that.

Eg. for xterm you may have to set *colorBDMode: false in .Xresources if it was disabled somehow. The same goes for italic and underlined characters: *colorITMode: false, *colorBLMode: false.

  • Thanks, I didn't realize you could set bold without specifying a color. So in summary, \e[1m sets bold. – wxyz Nov 13 '18 at 22:51
0

Bold is a character-related video attribute, usually thicker lines, but which in some devices is imitated using bright colors (a change in intensity).

RGB already gives the color intensity, so at most you'll find some terminals doing something like changing the levels a little — but nothing that you can count on in different terminals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.