wiki:256Colors

Version 12 (modified by andersk@mit.edu, 13 years ago) (diff)

Syntax highlighting

BarnOwl has built-in support for 256-color terminals, assuming your libncursesw (and GNU Screen, if you're using it) support it.

Outside of screen, your TERM environment variable must be set to xterm-256color instead of xterm. If you're running BarnOwl out of the locker, the barnowl-256color wrapper sets this for you. But to get 256 color support for all programs, put something like this in your ~/.bashrc:

case "$TERM" in
    xterm) TERM=xterm-256color;;
esac

In Ubuntu before 9.04 you also need to install the ncurses-term package.

As of Debian Lenny, the stock screen is built with 256 color support. To enable it, first make sure your outer TERM is xterm-256color as above, and add the following to your ~/.screenrc:

# Erase background with current bg color
defbce on
# Advertise 256 color support to inner applications
term screen-256color-bce

(If for some reason you do not want to set your outer TERM to xterm-256color, you can teach screen how to use 256 colors anyway by adding: termcapinfo xterm 'Co#256:AB=\E[48;5;%dm:AF=\E[38;5;%dm')

For older platforms, the barnowl locker may have a newer screen under the name of screen-256color; /mit/barnowl/etc/screenrc includes the aforementioned additions.

In case you want to use 256-color Emacs inside screen, see Emacs bug 2650.

Debian has a bug that prevents underlining from working in screen-256color. To fix it, run

tic /dev/stdin <<EOF
screen-256color|GNU Screen with 256 colors,
        use=screen,
        ccc, colors#256, pairs#32767,
        initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
        setab=\E[48;5;%p1%dm, setaf=\E[38;5;%p1%dm, setb=\E[48;5;%p1%dm, setf=\E[38;5;%p1%dm,

screen-256color-bce|GNU Screen with 256 colors and BCE,
        use=screen-bce,
        ccc, colors#256, pairs#32767,
        initc=\E]4;%p1%d;rgb\:%p2%{255}%*%{1000}%/%2.2X/%p3%{255}%*%{1000}%/%2.2X/%p4%{255}%*%{1000}%/%2.2X\E\\,
        setab=\E[48;5;%p1%dm, setaf=\E[38;5;%p1%dm, setb=\E[48;5;%p1%dm, setf=\E[38;5;%p1%dm,
EOF