TL;DR
How can I change these colors[?]
You can change these colors with an .Xresources
file.
[I]s there a way to use #xxxxxx colors?
Yes. For example xterm*color1: ffa70a
( though I don't suggest lightsalmon
as your xterm*color1
). Note that, I imagine among other specifications, you can use an equivalent option - xterm*color1: rgb:ff/a7/0a
- which I think is a bit more readable (especially for people just learning *NIX systems; if you feel better with the #ffa70a
, feel free to use it).
An example of making all colors less bright than the defaults is:
$ cd
$ test -f .Xresources && \
cp .Xresources .Xresources.$(date '%s').bak \
# backing up existing .Xresources if it exists
$ test -f .Xresources || touch .Xresources \
# creating .Xresources if it doesn't exist
Edit ~/.Xresources
using your favorite editor For this example, the file should end up as
xterm*color1: gray40
xterm*color2: red5
xterm*color3: green5
xterm*color4: yellow5
xterm*color5: magenta5
xterm*color6: cyan5
xterm*color7: white5
xterm*color8: gray50
xterm*color9: red2
xterm*color10: green2
xterm*color11: yellow2
xterm*color13: magenta2
xterm*color14: cyan2
xterm*color15: white2
Run
$ xrdb -merge ~/.Xresources
Then, your
$ xterm &
should bring up something less bright.
I should mention one resource in the TL;DR, because it has been so useful for me with xterm
, etc.
Thomas E. Dickey's Invisible Island: XTerm FAQs
Details
@Gilles_'SO-_stop_being_evil' has a great answer - I especially liked the information on how to preview a color from the terminal with printf
and the escapes for the ascii color codes.
The answer from @Gilles helped me to find out how to fix my too-bright XTerm stuff. The part that was bothering me was the bright green of the <username>@<machine-name>
. (See Note {1} for my reasons not to have a screenshot.) I wasn't able to get the change using any of the listed colors, and I didn't really understand how to use the info that
If your xterm is compiled with 16-color support, replace [3 and [4 by [9 and [10 respectively to select the bright versions (colors 8–15).
I was led to look at the documentation from X.org. If that previous link, which points to
https://www.x.org/releases/X11R6.7.0/doc/xterm.1.html#:~:text=color0%20%28class%20Color0%29
doesn't take you to the part of the page with "color0 (class Color0)", then do a Ctrl+f
for "color0 (class Color0)". In the docs, there's nothing listed after color0
-color6
, but after color7
one can read
These specify the colors for the ISO-6429 extension. The defaults are, respectively, ...
After this, the colors match the table from @Gilles, but I show what's in the docs. I repeat it to give a second way of seeing it, as well as to add emphasis with bold text and notes I've added inside square brackets.
... The defaults are, respectively,
black [meaning color0
],
red3 [meaning color1
],
green3 [color2
],
yellow3 [color3
],
DodgerBlue1 [color4
],
[ Note that linux.die.net/man/1/xterm
and
man xterm | grep -B9 -A32 color4
both list 'a customizable dark blue'
for what matches with color4
. ]
magenta3 [color5
],
cyan3 [color6
],
and gray90 [color7
].
For the RGB (or other color-space) coordinates of these named colors, find X11
's rgb.txt
using find /usr/share/ -type f -name "rgb.txt" 2>&1 | grep -i "X11"
, or, if that doesn't work, find /usr/ -type f -name "rgb.txt" 2>&1 | grep -i "X11"
. I've seen a lot of resources that list it at /usr/X11R6/lib/X11/rgb.txt
, but on my machine (see Note 2) it's at /usr/share/X11/rgb.txt
.
Further, there's nothing listed after color8
-color14
, but after color15
one can read
These specify the colors for the ISO-6429 extension if the bold attribute is also enabled. The default resource values are respectively,
gray30 [color8
],
red [color9
],
green [color10
],
yellow [color11
],
SteelBlue1 [color12
],
[ Note that linux.die.net/man/1/xterm
and
man xterm | grep -m1 -B34 -A5 color15
both list 'a customizable light blue'
for what matches with color12
. ]
magenta [color13
],
cyan [color14
],
and white [color15
].
As for 'if the bold attribute is enabled', this is the case unless you've changed the defaults, for example by adding xterm*boldMode: false
to your .Xresources
or .Xdefaults
.
With all this information, I was able to fix my too-bright-green problem by making an .Xresources
file in my home directory ( cd
; touch .Xresources
). I chose this instead of .Xdefaults
, because I read somewhere that .Xdefaults
is deprecated. I don't have the source for that, sadly. Then, I added the line,
xterm*color10: green2
(green2
is less bright that green
and more bright than green3
)
and running
xrdb -merge ~/.Xresources
To make the other bold colors less bright, one could have in one's .Xresources
the following:
xterm*color8: gray20
xterm*color9: red2
xterm*color10: green2
xterm*color11: yellow2
xterm*color13: magenta2
xterm*color14: cyan2
xterm*color15: white2
You could also make everything less bright by doing something like xterm*color3: green3
with xterm*color10:green6
, etc. for the other pairs of colors.
You can also use hex ( #xxxxxx
) and RGB decimal values. I don't doubt that you can use other specifications of colors, too. So, in answer to your questions:
How can I change these colors, is there a way to use #xxxxxx colors?
You can change these colors with an .Xresources
file.
AND
You can use #xxxxxx
colors with, e.g. xterm*color10: #00ee00
(respectively).
Notes:
{1} I would post a screenshot, but as of now (2021-12-23), StackExchange sites seem to be having trouble with attached images, and I can't put a backup from the Wayback Machine here at work.
{2} The following command and output show my machine information. I'm running RHEL 8, RHEL standing for Red Hat Enterprise Linux.
$ uname -a
Linux MYMACHINE 4.18.0-240.10.1.el8_3.x86_64 #1 SMP Wed Dec 16 03:30:52 EST 2020 x86_64 x86_64 x86_64 GNU/Linux
Other useful resources:
Color names and locations in color spaces
An SO answer that has useful comments describing what certain color[1]?[0-9]
will affect
ArchLinux: Understanding Xdefault terminal colors
What are the colors[0..15] used for in xterm?
Examples of application-specific .xresources
AstroBetter - Customizing xTerm and Terminal: colors , be careful to back up your LS_COLORS
environment variable, e.g. echo $LS_COLORS > ~/.env_LS_COLORS.$(date +'%s').bak
before trying these things.
Very close to what I ended up using, note that this disables the bold, as I ended up doing.
Perhaps the most useful: Thomas E. Dickey's Invisible Island: XTerm FAQs