wiki:256colors

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)
        read -d '' terminal terminal_args < /proc/$PPID/cmdline
        case "${terminal##*/}" in
            gnome-terminal*|xterm*) TERM="$TERM-256color";;
        esac
        unset terminal terminal_args
        ;;
esac

(Or wait for a configurable TERM in gnome-terminal?)

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'. This is not recommended because it will break 16-color terminals that advertise TERM=xterm.)

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.

Bugs

In case you want to use 256-color Emacs inside screen, see Emacs bug 2650 (fixed in Emacs 24).

ncurses before ncurses 5.8 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
Last modified 2 years ago Last modified on Mar 15, 2012, 11:21:28 PM