TITLE: 256 color xterm DATE: 2003-10-03 LFS VERSION: any AUTHOR: Randy Hron SYNOPSIS: How to build a 256 color capable xterm. DESCRIPTION: This hint assumes you've already installed XFree86 and want an xterm that supports more than 16 colors. PREREQUISITES: XFree86 CHANGELOG: Mon Sep 15 20:55:36 EDT 2003 Updated for XFree86-4.3.0.1. Other than the tarballs to extract in step 2, this applies to earlier versions of XFree86 4.x. (Back when there were only 3 tarballs for XFree86, xterm was in the first tarball). Fri Oct 3 22:09:52 EDT 2003 Reference vim-6.2. Use xterm-color as TERM. Make test programs executable. Tested with 4.3.99.12. LICENSE: GNU Free Documentation License HINT: XFree86 builds a 16 color capable xterm by default. If you want to run vim or other color capable programs, you may want an xterm that does more colors. 1. How many colors do I have? You can check how many colors your xterm knows with the command: strings /usr/X11R6/bin/xterm | grep ^color[0-9] | sort -tr +1 -n This command has to be executed as root, since xterm is setuid and is not readable by normal users. It may print something like: color0 color1 .. color14 color15 If that is all you get, you have a 16 color xterm. If the list keeps going to color255, you already have a 256 color xterm. 2. Building a 256 color xterm If you already removed your xc tree, don't despair. You can recompile xterm without compiling the World. If you don't still have the xc tree extracted, just extract X430src-1.tgz and X430src-2.tgz. xterm is in the second tarball. cd xc/programs/xterm && rm -f *.o xmkmf && sed 's/_WIDE_CHARS/_WIDE_CHARS -DOPT_256_COLORS -DDFT_TERM_TYPE=xterm-color/' \ Makefile > Makefile~ && mv Makefile~ Makefile && make && strings xterm | grep ^color[0-9] | sort -tr +1 -n This time you should see a list of colors that counts to color255 color0 color1 .. color254 color255 4) Install the new xterm make install 5) Update your TERM variable Use xterm-color as your TERM type. You may want something like this in your /etc/bashrc: case `tty` in */pty*|*/pts/*) export TERM=xterm-color ;; esac 6) Xdefaults Different X apps/window managers may use either .Xresources or .Xdefaults to change their default behavior. Here are some things in my .Xdefaults to make colors more enjoyable: ! Pick your favorites from /usr/X11R6/lib/X11/rgb.txt ! Be sure to use the "OneWord" value for a color, and not ! the "two words" value. ! xterm*background: black ! xterm*foreground: green *loginShell: true ! Use color for underline attribute *VT100*colorULMode: on *VT100*underLine: off ! Use color for the bold attribute *VT100*colorBDMode: on ! Love scrollback *VT100*saveLines: 5000 *VT100*scrollBar: true ! Use -color app-defaults in /usr/X11R6/lib/X11/app-defaults *customization: -color Make your new ~/.Xdefaults take effect without restarting X with: xrdb -merge ~/.Xdefaults 7) Vim To have syntax highlighting in vim, have this in your ~/.vimrc: syntax on 8) Log all the way out and come back in. You can do a combination of xrdb and sourcing your .bash_profile, but your window manager will still think your TERM is xterm and not xterm-color. To eliminate confusion, just log out to xdm or the login prompt and come back in. 9) Checking colors There are several nifty xterm tests in xc/programs/xterm/vttests. The fastest one for testing colors is 256colors2.pl. Just run: chmod +x *.pl /256colors2.pl 10) Testing vim colors Vim has a colortest program that you run with vim: vim /usr/share/vim/vim62/syntax/colortest.vim >From inside vim, type: :source % I counted about 23 colors in this test, but it's nice seeing the words associated with the colors. 11) Have fun. Let me know if something here is inaccurate or could be better. 12) Thanks to Gerard and everyone at Linux From Scratch.