0

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!

ProdIssue
  • 875

3 Answers3

2

$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

JdeBP
  • 68,745
  • 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. – ProdIssue 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. – ProdIssue May 15 '18 at 13:30
0
  1. Place this in your ~/.screenrc, create and add if not exists
    shell -$SHELL
    
  2. Place this in your ~/.bashrc or ~/.zshrc, whichever shell you have configured.
    export TERM=screen-256color
    
  3. Apply the changes
    source ~/.zshrc
    screen -S screen_name
    
AdminBee
  • 22,803
venkat
  • 101
0

Try these commands in screen session:

alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l.='ls -d .* --color=auto'
alias ll='ls -l --color=auto'
alias ls='ls --color=auto'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
Spark
  • 1