2

I might not have found the best title for this. I am not really asking for help since I can accomplish what I want. I just want to know, if I understand everything right. But please, see for yourself:

I can set 256 colors in my termite config file like this:

colorx = #xxxx

for example:

color255 = #8fa200

which gives a nice green.

They are usable for LS_COLORS via a .dircolors file with the syntax:

<filetype> <effects>38;5<foreground>;48;5;<background>

e.g.:

DIR 04;38;5;255

for underlined directories using the specified green. Obviously this works for X. Now in regard to tty I am getting the standard blueish tint for directories. I can influence the actual colors used with entries in my .bashrc like:

echo -en "\e]PCffa500"

I can hack together a pretty consistent color scheme throughout my system with this.

The question is: Am I right in my understanding that ls --colors=auto is falling back to the precompiled dircolors because I am using 256 color descriptions for X? Or is there actually another mechanic controlling that? And therefore maybe even finer grained control possible.

Looking forward to learn from your wisdom...

| improve this question | | | | |
1

GNU ls doesn't know anything about the terminal's control sequences. It simply relates the $TERM environment variable to its table (whether from the $LS_COLORS environment variable, or its compiled-in defaults doesn't matter much). None of that tells it how many colors the terminal has.

If you read the source code (dircolors.c, ls.c), you might notice that it does not use the number of colors in deciding what to print. Whether it uses the escape sequences for 256-colors or not appears to depend on who the packagers were (it's not in the coreutils source-code, though a comment hints at the possibility).

It does not use the terminal database; any resemblance between that and GNU ls is basically that the latter uses names of terminal descriptions without using the corresponding information. So it pretends that VT100s used color (see ncurses FAQ).

Since the compiled-in values use 8-color ANSI (and assumes that bold-colors add another 8), if you see it using 256-colors, that is due to the way the (external to GNU ls) configuration files are set up under /etc.

| improve this answer | | | | |

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.