8

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?

migrated from stackoverflow.com Feb 7 '12 at 17:34

This question came from our site for professional and enthusiast programmers.

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

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

  • 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! – hekevintran Apr 1 '12 at 0:59
  • FWIW, I reported this as a bug at bugreport.apple.com, so hopefully this will get fixed in Mountain Lion. – Mathias Bynens Apr 1 '12 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 '13 at 11:34
1

Add the following to your ~/.screenrc

term "screen-256color"

And then try, it should work.

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

You must log in to answer this question.

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