enable 256 color support

Bug #409353 reported by Scott Moser on 2009-08-05
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Dustin Kirkland 
byobu (Ubuntu)
Dustin Kirkland 

Bug Description

bug 87966 has instructions on how to setup 256 color support in screen.

in short, enable it by these screenrc commands:
# 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"

then, to test it:
wget http://www.frexx.de/xterm-256-notes/data/256colors2.pl -O 256colors2.pl && perl ./256colors2.pl

Changed in byobu:
status: New → Fix Released
Jason Cohen (kryojenik) wrote :

Support is only 95% there... byobu (screen) supports 256 colors but reports to ncurses apps via term info that it only supports 8 colors.

The TERM variable while in screen is TERM=screen or TERM=screen-bce. If you defbce in screenrc, screen is smart enough to set the TERM to screen-bce. However, the screen and screen-bce terminfo files state they are 8 Color terminals. So when you run ncurses apps they will look at the terminfo capabilites and see you are only an 8 color terminal.

You can set term screen-256color-bce in your screenrc to set this correctly (at least in karmic). That terminfo exists and is a 256 color terminal (as is screen-256color).

Or you can set in the command line to screen.

screen -T screen-256color. Again, if you have defbce set in screenrc screen will add the -bce to the term for you.

Ultimately it would be nice for screen itself to check if the term supports 256 colors and then set an appropriate TERM based on that.

As a fix to byobu in the meantime...

patch attached ... and:

--- /usr/bin/byobu.orig 2010-01-09 22:38:29.253840432 -0500
+++ /usr/bin/byobu 2010-01-09 17:48:47.742590537 -0500
@@ -44,9 +44,12 @@
 DEFAULT_WINDOW="$SHELL -c motd+shell"
 grep -qs "^[^#]" "$HOME/.$PKG/windows" && DEFAULT_WINDOW=

+# Check if our terminfo supports 256 colors
+[ -x /usr/bin/tput ] && [ $(/usr/bin/tput colors) -eq 256 ] && SCREEN_TERM="-T screen-256color"
 # Now let's execute screen!
 if [ "$#" = "0" ]; then
- exec screen -c "/usr/share/$PKG/profiles/byoburc" $DEFAULT_WINDOW
+ exec screen $SCREEN_TERM -c "/usr/share/$PKG/profiles/byoburc" $DEFAULT_WINDOW
- exec screen -c "$HOME/.$PKG/profile" "$@"
+ exec screen $SCREEN_TERM -c "$HOME/.$PKG/profile" "$@"

When connecting from putty or SecureCRT send xterm-256color to get a host terminfo that supports 256 colors.

Jason Cohen (kryojenik) wrote :

Forgot to attach the patch...

Changed in byobu:
status: Fix Released → New
Dustin Kirkland  (kirkland) wrote :

Hi Jason-

Thanks for the patch.

I'm not sure I quite understand it, yet...

See the attached screenshot. This is byobu, on karmic, running in gnome-terminal. Running the perl script, it certainly looks to me like I have 256 colors. However, tput stills shows 8. And the TERM is set to screen-bce.

I'm happy to take the patch, but I want to more clearly document what subset of users are positively affected by this, and that other users won't be harmed by it.


Changed in byobu:
status: New → Incomplete
importance: Undecided → Wishlist
Jason Cohen (kryojenik) wrote :

I don't think your screenshot got attached, but no worries. I ran the test as well. Yes, byobu does in fact support the 256 colors, and when sending them to an Xterm that can do 256 colors they are displayed. That isn't where the problem lies.

The problem occurs when running ncurses app within screen with the 8 Color terminfo. ncurses apps look up the value in the terminfo database and sets its output from that. A specific example is vim.

When the term is set to one that only supports 8 colors, that is all vim sees.
:echo &t_Co in vim returns 8.

When you set TERM=screen-256color-bce then vim will see that it can output 256 colors by way of the terminfo database.
:echo &t_Co in vim will now return 256.

Here are a couple of 256 color schemes for vim. You will never want to use 8 color vim again. :)

http://www.vim.org/scripts/script.php?script_id=1243 - 256 colro desert theme
http://www.vim.org/scripts/script.php?script_id=1143 - inpot

Jason Cohen (kryojenik) wrote :

There are a couple of small side effects so far...

The screen-256color-bce and screen-bce terminfos have a slight diffrence. I am submitting a bug the maintainers of that as soon as I find it. I think it is responsibility of the ncurses package.

And dircolors. For some silly reason dircolors depends on hard coded TERM names within the compiled binary. screen-256colors-bce isn't included. Submitting a bug there too, but my workaround is:

#TERM=screen-bce dircolors > ~/.dircolors

Then add a "TERM screen-256color-bce" line in with the terms.


Jason Cohen (kryojenik) wrote :

Quick edit to the above dircolors line...

That should have been

user@host:~$ TERM=screen-bce dircolors -p > ~/.dircolors

screenshot attached this time ;-)

Changed in byobu:
status: Incomplete → Confirmed
status: Confirmed → Triaged
Changed in byobu:
status: Triaged → Fix Committed
assignee: nobody → Dustin Kirkland (kirkland)
Changed in byobu (Ubuntu):
status: New → Fix Committed
importance: Undecided → Wishlist
assignee: nobody → Dustin Kirkland (kirkland)
Jason Cohen (kryojenik) wrote :

For those landing here and your 'ls' listing is now missing colors...

Use the command in post 6 above and a bug for dircolors is:


Changed in byobu:
status: Fix Committed → Fix Released
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package byobu - 2.47-0ubuntu1

byobu (2.47-0ubuntu1) lucid; urgency=low

  [ Dustin Kirkland ]
  * usr/lib/byobu/network: fix network script regresssion, LP: #506315
  * usr/lib/byobu/wifi_quality: silence error
  * byobu.desktop, byobu.svg: install these again, but hide the menu item
    by default, per pitti's fallback suggestion to LP: #498322
  * Make byobu more portable, much help from Derek Carter, LP: #503554
    - debian/rules, debian/manpages, usr/share/man/man1/*: move the manpages
      to make byobu more portable
    - debian/install, bin/*, usr/lib/byobu/*: move the status scripts
    - debian/install, usr/share/byobu/*: move the share files
    - debian/install, usr/bin/*: move the binary scripts
    - debian/install, usr/share/doc/byobu/*: move the docs
    - debian/install, etc/*: move the config file
    - debian/install, debian/rules, po/*: move the translations
    - usr/share/applications/byobu.desktop, usr/share/byobu/pixmaps/byobu.svg:
    - usr/share/byobu/tests/byobu-time-notifications: relocate, rename, and
      install the notification timing tests, add a copyright header
    - AUTHORS, ChangeLog, NEWS: added
  * bin/byobu-launcher, bin/byobu-select-session,
    share/man/man1/byobu-select-session.1: add a dynamic prompt if
    automatically launching byobu on a server where multiple sessions
    exist, LP: #368963
  * byobu-export, byobu-janitor, byobu-status: default to white text on
    black backgrounds

  [ Jason Cohen ]
  * usr/bin/byobu: check if our terminfo supports 256 colors, LP: #409353
 -- Dustin Kirkland <email address hidden> Mon, 11 Jan 2010 22:54:36 -0600

Changed in byobu (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers