9

Terminal.app in Mac OS X Lion has a feature that took a long time to get implemented: 256 color support. The colors work fine. The issue I'm having is that when I run GNU Screen I do not have access to 256 colors. In screen, $TERM is set to "screen".

I've read different things in different places and am very confused. Some of these include:

  • GNU Screen must be compiled with color support (How can I tell if OS X's screen was compiled this way?)
  • A special terminfo file for screen-256color must be installed. Does OS X have this?
  • In .screenrc, term should be set to "screen-256color".
  • Certain functions in Emacs must be called for Emacs to be colorful (http://www.emacswiki.org/emacs/GnuScreen#toc6)

I tried variations of these procedures and have been unsuccessful and uncertain of why I have failed. What is the most direct way for me to enable 256 colors in GNU Screen?

1
  • 1
    @PaulR You're right, but it's a good question nevertheless.
    – Thomas
    Feb 6, 2012 at 23:11

2 Answers 2

7

By default, screen is not aware that it is running in a 256-color-capable xterm. To make programs in screen recognize this feature, you need to set a couple of things in your ~/.screenrc:

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

If this doesn’t work for you, your version of screen probably wasn’t compiled with ./configure --enable-colors256. You can check this in the welcome screen when starting screen. The default version that comes with OS X doesn’t support 256 colors. You could check out the source and compile your own version, putting the resulting binary in your $PATH (I put it in ~/bin which I added to my $PATH):

git clone git://git.savannah.gnu.org/screen.git
cd screen/src
./autogen.sh
./configure --enable-colors256
make   # I got a lot of warnings here, but they don't seem to matter
sudo make install
cp screen ~/bin/screen

Sources: 1 and 2

4
  • 1
    Thank you very much. This issue has been irritating me for so long. Someone at Apple thought it was a good idea to ship a terminal emulator with 256 colours and a terminal multiplexer with 8 haha! Apr 1, 2012 at 0:59
  • FWIW, I reported this as a bug at bugreport.apple.com, so hopefully this will get fixed in Mountain Lion. Apr 1, 2012 at 5:58
  • 2
    Homebrew users: homebrew-dupes has a recipe for screen including --enable-colors256. $ brew tap homebrew/dupes # if you haven't already $ brew install screen
    – chrisk
    Apr 1, 2013 at 11:34
  • I cannot use the solution for big sur anyone could help? I have install via brew install screen but it still use 8 bit colors screen
    – buncis
    Dec 20, 2020 at 5:11
1

Add the following to your ~/.screenrc

term "screen-256color"

And then try, it should work.

2
  • FWIW this is all I needed in 10.7.5 and 10.8.2.
    – tvon
    Dec 19, 2012 at 15:59
  • @tvon I can't get it work on my OSX 10.7.5. Any idea why?
    – Phani
    Sep 19, 2013 at 16:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .