1

I am having trouble customizing the color of my caption in screen. I can use the 8 standard colors supported (as well as their brighter versions), but I am unable to define a custom color.

The docs for screen state: "Colors are coded either as a hexadecimal number or two letters". It does not seem to define anywhere what format to write the hex number in. I have tried several random ways but so far none seem to work.

Does anyone know how to use a custom color in screen?

5
  • screen doesn't get the last word on this, the capabilities of the terminal do. Most only have 16 colors -- two versions of the basic eight -- and custom colors won't work.
    – goldilocks
    Dec 4 '13 at 15:58
  • @goldilocks I know my terminal supports more colors than this - VI displays some of my text in a nice muted green that I want to use.
    – MrGlass
    Dec 4 '13 at 16:58
  • Konsole, gnome-terminal, and some others are capable of 256 colors, but it's still a pre-configured fixed palette. Try echo -e "\\033[32mhey\\033[1mhey\\033[0m" and see if one of those is the green you are looking for.
    – goldilocks
    Dec 4 '13 at 17:13
  • @goldilocks Hmm, those seem to be showing similar colors. Out of curiosity, do you know how I would specify a color code like that for caption?
    – MrGlass
    Dec 4 '13 at 17:35
  • Those are the two greens; the first is the basic green and the second bright aka. bold green. The [NNm numbers are ANSI codes: en.wikipedia.org/wiki/ANSI_escape_code#Colors If you scroll up and look at the "SGR parameters" chart above that you'll notice 30-37 is foreground and 40-47 background. You could try translating those to hex and see if they work; [1m adds the bold and [0m resets.
    – goldilocks
    Dec 4 '13 at 18:00
1

Here is an example for caption:

caption always "%{= 2f} CAP %3n %t"

I added the string CAP just to prove that the caption is being used. According to the manual, the default for this is "%3n %t".

You apply attributes and colors within the "%{ }" markers. Attributes come first, and it is simplest to set a color if you just force a dummy attribute (as I do here with "=" followed by a blank.

The 2f is a hexadecimal color value (a green background: just a 2 would give green text). The intent of the hexadecimal number is to give values 0-15 for each of the background and foreground colors.

By the way, there is no direct relationship between colors used in caption, etc., versus the colors that an application may use when running inside screen: the latter can be more than 16 colors, while attributes cannot. To see this, you would have to read the source code because the documentation is lacking in detail, e.g,.

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.