I recently installed GNU screen on a machine I ssh into. How do I get GNU screen to use 256 colors?

So far, I've tried adding the following to my .screenrc:

term screen-256color


attrcolor b ".I"    # allow bold colors - necessary for some reason
termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm'   # tell screen how to set colors. AB = background, AF=foreground
defbce on    # use current bg color for erased chars

but neither worked.

In the login shell, before I start screen, when I run this script, which prints 256 colors, I get normal output. When I use the command tput colors I get the output 8.

When I start screen and run the script, I get 16 colors mapped to 256 colors - there are large blocks of solid color. When I run tput colors I get 256 (when term screen-256color is in my .screenrc).

edit: I got it to work - I didn't configure screen with the --enable-colors256 option.

  • What does echo $COLORTERM say? Dec 12, 2011 at 15:41
  • undefined, but I got it to work - I recompiled it with the --enable-colors256 option.
    – Scott
    Dec 12, 2011 at 16:18
  • I have file names in color, but command prompt in black-and-white. Is you prompt in color also? (I mean - after you've re-build it yourself)
    – Adobe
    Jan 30, 2012 at 9:31

2 Answers 2


I personally put it in ~/.bashrc

export TERM=xterm-256color

If that does not work, what terminal are you using ?

  • 1
    This is what fixed it for me. Need this in ~/.bashrc and the 3 lines listed in the original question for attrcolor, termcapinfo and defbce in the .screenrc. Thanks.
    – Matthew
    Apr 24, 2013 at 16:43
  • This worked. But adding the other stuff to ~/.screenrc makes everything output escape sequences instead of colors, like some sort of alien terminal.
    – trusktr
    Jul 9, 2014 at 0:55
  • This should be the accepted answer. Fixed an annoying bug I never got round to for ages. Jul 17, 2019 at 4:16
  • .bashrc is a wrong place for setting TERM variable. See jdebp.eu./Softwares/nosh/guide/TERM.html#MIS-CONFIGURATION
    – Arusekk
    Apr 4, 2020 at 18:21

If you built screen from source you'll need to recompile it with the 256 color flag enabled. Run ./configure --enable-colors256 && make && sudo make install

  • This was my problem! I recompiled the source code, and added those three lines to my .screenrc! Oct 31, 2014 at 5:46

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.