From Fedora Project Wiki
(Created page with "= 256 Color Terminals = == Summary == Enable terminal programs to use the enhanced color capabilities of modern terminals by default. I.E. increase their color options from the...")
 
No edit summary
Line 4: Line 4:
Enable terminal programs to use the enhanced color capabilities of modern terminals by default.
Enable terminal programs to use the enhanced color capabilities of modern terminals by default.


I.E. increase their color options from the 16 colors at the top of this picture,
I.E. increase their color options from the 8 colors at the top of this picture,
to the other 256 displayed.
to the other 256 displayed.


Line 21: Line 21:
Many terminal programs (like '''vim''' and '''ls''' for example) can take advantage of 256 color terminals,
Many terminal programs (like '''vim''' and '''ls''' for example) can take advantage of 256 color terminals,
and all xterms I know of support at least 256 colors and sometimes more.<br/>
and all xterms I know of support at least 256 colors and sometimes more.<br/>
So let's break through the artificial 16 color limit!
So let's break through the artificial 8 color limit!


Also when preparing this page, while searching the net I noticed that
Also when preparing this page, while searching the net I noticed that
Line 32: Line 32:


== Benefit to Fedora ==
== Benefit to Fedora ==
By having 16 times more colors available gives much better scope for using more appropriate default colors.
By having 32 times more colors available gives much better scope for using more appropriate default colors.
For example, users could set their terminal backgrounds to dark or light and have '''ls''' use colors
For example, users could set their terminal backgrounds to dark or light and have '''ls''' use colors
that are appropriate to either.
that are appropriate to either.
Line 60: Line 60:
editing the /etc/DIR_COLORS.256color file in the coreutils package, as it
editing the /etc/DIR_COLORS.256color file in the coreutils package, as it
doesn't take as much advantage of the color range as it could.
doesn't take as much advantage of the color range as it could.
As the default <tt>vim</tt> color scheme has some issues in 256 colors, we should also provide updates on this. <tt>Search</tt>, <tt>SpellLocal</tt>, <tt>ColorColumn</tt> and <tt>MatchParen</tt> are hardly readable (see <tt>:hi</tt> under <tt>vim</tt>).


== How To Test ==
== How To Test ==

Revision as of 21:53, 17 June 2012

256 Color Terminals

Summary

Enable terminal programs to use the enhanced color capabilities of modern terminals by default.

I.E. increase their color options from the 8 colors at the top of this picture, to the other 256 displayed.

16 to 256.png

Owner

Current status

  • Targeted release: Fedora 18
  • Last updated: 2012-06-16
  • Percentage of completion: 50%

Detailed Description

Many terminal programs (like vim and ls for example) can take advantage of 256 color terminals, and all xterms I know of support at least 256 colors and sometimes more.
So let's break through the artificial 8 color limit!

Also when preparing this page, while searching the net I noticed that Mac OS X Terminal's default $TERM value is xterm-256color since Lion 10.7 That will ease some of the compatibility issues noted below.

You can see vim's default appearance using the above expanded palette at:

http://www.pixelbeat.org/docs/terminal_colours/#256

Benefit to Fedora

By having 32 times more colors available gives much better scope for using more appropriate default colors. For example, users could set their terminal backgrounds to dark or light and have ls use colors that are appropriate to either.

Also more subtle and considered coloring can be used as discussed and depicted at: https://github.com/seebi/dircolors-solarized

Scope

This will be mainly configuration changes. I think the most easily configurable/maintainable option is to have a new /etc/profile.d/256color.sh file. That will keep the config central, and set things up in a standard way such that LS_COLORS will be set appropriately.

Here is my current version:

[ "$TERM" = 'xterm' ] && TERM=xterm-256color
[ "$TERM" = 'screen' ] && TERM=screen-256color
[ "$TERM" = 'rxvt-unicode' ] && TERM=rxvt-unicode-256color
export TERM

if [ ! -z "$TERMCAP" ] && [ "$TERM" = "screen-256color" ]; then
  TERMCAP=$(echo $TERMCAP | sed -e 's/Co#8/Co#256/g')
  export TERMCAP
fi

As an optional additional improvement, we could adjust the 256 color values used in ls by editing the /etc/DIR_COLORS.256color file in the coreutils package, as it doesn't take as much advantage of the color range as it could.

As the default vim color scheme has some issues in 256 colors, we should also provide updates on this. Search, SpellLocal, ColorColumn and MatchParen are hardly readable (see :hi under vim).


How To Test

Test as many colored terminal apps as possible under as many terminals as possible. Ensure screen works as expected too. There are screen testing notes at: http://www.robmeerman.co.uk/unix/256colours

For testing any ls color changes you can use this command:

eval $(dircolors /etc/DIR_COLORS.256color)
echo $LS_COLORS | tr : '\n' | sed 's/\(.*\)=\(.*\)/\x1b[\2m\1\t\2\x1b[0m/'

User Experience

Better default colors with less tweaking required.

Dependencies

None

Contingency Plan

None necessary, revert to previous release behaviour

Documentation

Caveats

  • The linux terminal (i.e. those on virtual consoles) doesn't support 256 colors and will break if applications send 256 color codes to it. This is handled in the config file above.
  • Local xterms support this feature fine, though once you connect to other systems with SSH (which propagates the TERM environment variable), they will have to support the $TERM, or otherwise you will have a degraded experience. Debian for example traditionally didn't support xterm-256color unless the ncurses-term package was installed. Note ubuntu 12.04 at least does support xterm-256color so this is improving. Also as noted above Mac OS X 10.7 defaults to xterm-256color and so they're paving the way somewhat in this regard, so there should be less issues in connecting to older systems going forward.

Release Notes

Probably worth mentioning the case where users may need to reset their TERM to 'xterm' etc. when sshing to older systems.

Comments and Discussion