Typo
[linux_from_scratch_hints.git] / OLD / xterm-256color.txt
blobc3195d5920d039cca62e76df473e2c9accae3231
1 TITLE:          256 color xterm
2 LFS VERSION:    any
3 AUTHOR:         Randy Hron <rwhron@earthlink.net>
5 SYNOPSIS:
6         How to build a 256 color capable xterm.
8 HINT:
9         XFree86 builds a 16 color capable xterm by default.
10 If you want to run vim or other color capable programs, you may
11 want an xterm that does more colors.
13 This hint assumes you've already installed XFree86.  Check out
14 the x11.txt hint if you haven't.  If you've already graduated to
15 KDE, GNOME, Eterm or "the console", you may not need this either.
17 1. How many colors do I have?
18 You can check how many colors your xterm knows with the command:
20 strings /usr/X11R6/bin/xterm | grep ^color[0-9] | sort -tr +1 -n
22 This command has to be executed as root, since xterm is setuid
23 and is not readable by normal users.  It may print something like:
25 color0
26 color1
28 color14
29 color15
31 If that is all you get, you have a 16 color xterm.  If the list keeps
32 going to color255, you already have a 256 color xterm.
34 2. Building a 256 color xterm
35 If you already removed your xc tree, don't despair.  You can recompile
36 xterm without compiling the World.  The xterm program is in the first 
37 XFree86 tarball, X410src-1.tgz.  You won't need tarball 2 or 3 for this
38 hint.  Here are the steps after you extract the tarball:
40 cd xc/programs/xterm &&
41 xmkmf &&
42 sed 's/_WIDE_CHARS/_WIDE_CHARS -DOPT_256_COLORS -DDFT_TERM_TYPE=linux/' \
43         Makefile > Makefile~ &&
44 mv Makefile~ Makefile &&
45 make &&
46 strings xterm | grep ^color[0-9] | sort -tr +1 -n
48 This time you should see a list of colors that counts to color255
50 color0
51 color1
53 color254
54 color255
56 4) Install the new xterm
57 make install
59 5) Use linux as your TERM variable
60 Amazingly TERM=linux gives better colors than TERM=xterm-256color.  
61 This may already set if your /etc/inittab has entries like:
63 1:2345:respawn:/sbin/agetty tty1  38400 linux
64         
65 6) Xdefaults
66 Different X apps/window managers may use either .Xresources or .Xdefaults
67 to change their default behavior.  Here are some things in my .Xdefaults
68 to make colors more enjoyable:
70 ! Pick your favorites from /usr/X11R6/lib/X11/rgb.txt
71 ! Be sure to use the "OneWord" value for a color, and not
72 ! the "two words" value.  
73 ! xterm*background:       black
74 ! xterm*foreground:       green
75 *loginShell:            true
77 ! Use color for underline attribute
78 *VT100*colorULMode: on
79 *VT100*underLine: off
81 ! Use color for the bold attribute
82 *VT100*colorBDMode: on
84 ! Love scrollback
85 *VT100*saveLines: 5000
86 *VT100*scrollBar: true
88 ! Use -color app-defaults in /usr/X11R6/lib/X11/app-defaults
89 *customization: -color
91 Make your new ~/.Xdefaults take effect without restarting X with:
92 xrdb -merge ~/.Xdefaults
95 7) Vim
96 To have syntax highlighting in vim, have this in your ~/.vimrc:
98 syntax on
100 8) Log all the way out and come back in.  
101 You can do a combination of xrdb and sourcing your .bash_profile,
102 but your window manager will still think your TERM is xterm and
103 not linux.  To eliminate confusion, just log out to xdm
104 or the login prompt and come back in.
106 9) Checking colors
107 There are several nifty xterm tests in xc/programs/xterm/vttests.  
108 The fastest one for testing colors is 256colors2.pl.  Just run:
110 /256colors2.pl
112 10) Testing vim colors
113 Vim has a colortest program that you run with vim:
115 vim /usr/share/vim/vim58/syntax/colortest.vim
117 >From inside vim, type:
118 :source %
120 I counted about 22 colors in this test, but it's nice seeing
121 the words associated with the colors.
123 11) Have fun.  Let me know if something here is inaccurate or
124 could be better.
126 12) Thanks to Gerard and everyone at Linux From Scratch.
128 13) William S Gahr mentioned you can set TERM when you start
129 xterm with "xterm -tn linux".
131 Mon Dec 10 20:06:44 EST 2001