I have a RHEL 6.9 host that loses its color when starting a screen session. Vim colors and directory colors exist before starting the screen session. Here are a few settings to help troubleshoot:

  • $TERM returns screen
  • I am using force_color_prompt=yes in my bashrc
  • echo "$(tput setaf 1)red$(tput sgr0)" successfully prints out red (in red)

Any advice on how to fix is appreciated, thanks!

  • Did you try screen-16color? – Ignacio Vazquez-Abrams May 14 '18 at 15:06
  • How do I use that? Do I run it as a screen command or put it in .screenrc? – Pythonic May 14 '18 at 15:13

$TERM returns screen

You've told the programs that you are running under Screen to look at the screen entry from the terminfo database when they want to do terminal-related stuff like colourize output. That entry tells them (via the common ecma+color entry) that the terminal has 3-bit standard colour support from 1976.

In fact, your version of Screen can very likely support a lot more than that.

You are probably looking for the screen-256color entry, which tells them that the terminal supports 8-bit indexed colour, or even the screen-256color-bce entry which specifies 8-bit indexed colour capability and background colour erase capability.

You tell them this by simple dint of setting the TERM environment variable to the value screen-256color, or screen-256color-bce.

Further reading

  • screen honors the 256-color escapes in either case (checked an hour ago). – Thomas Dickey May 14 '18 at 20:49
  • It would, as its actual processing of SGR sequences is unaffected by the environment variable in some other process. The version of Screen that wouldn't support more than that would be one dating from before the introduction (into Screen) of 8-bit indexed colour support. I haven't checked when that was, because (as I said) it isn't the very likely case. (-: – JdeBP May 14 '18 at 20:55
  • In either case, the explanation of why there's no color appears to be missing. – Thomas Dickey May 14 '18 at 21:00
  • I tried screen defbce/bce on however the exec defbce or bce does not exist on the host. Also setting the TERM variable to one of the ones you suggested in and out of the screen session did not fix the issue. – Pythonic May 15 '18 at 13:21
  • I think there is some kind of limitation on this host. When I login to an ubuntu host start a screen session there and then have each terminal login to the problem host things work fine, I suppose because I am using the settings of the original host. – Pythonic May 15 '18 at 13:30

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.