piyo's computer tips
2006/04/05
256 colors on your terminal emacs and screen
color, terminal, command-line, Emacs, Screen, Windows

I got tired of ANSI colors on my Putty sessions to my Colinux Linux instances. I started researching if I could get more colors and the answer now is yes, 256 colors is possible. How do I get Emacs to take advantage of this and be just darn more colorful?

Screen settings:

On Debian sarge v3.1, you need to recompile screen so that it has --enable-256colors in the ./configure. This blog has the details on how to do it. Gentoo has this automatically.

Then add the following to your ${HOME}/.screenrc file, which was taken from "The 256 color mode of xterm" page. Really useful.
# erase background with current bg color
defbce "on"
# do not use 'screen-bce'
term xterm-256color
Putty settings:

For putty 0.58 on Windows, add the terminal name "xterm-256color" in the Data panel before starting a session. This Data panel is not customizable after you start a session.

Emacs settings:

GNU Emacs 21.x doesn't support this xterm-256color directly, but you can define the colors yourself. You could try this script where the colors are defined by number, or you can try my script which defines the colors to the nearest color in the rgb.txt.

(defmacro tty-color-define-1 (n c r g b)
`(tty-color-define ,n ,c (list (* 257 ,r) (* 257 ,g) (* 257 ,b))))
(defun tty-color-closest-to-rgb-txt ()
(tty-color-define-1 "grey22" 16 55 55 55)
(tty-color-define-1 "DarkSlateGrey" 17 55 55 95)
(tty-color-define-1 "SlateBlue4" 18 55 55 135)
(tty-color-define-1 "SlateBlue4" 19 55 55 175)
(tty-color-define-1 "RoyalBlue3" 20 55 55 215)
(tty-color-define-1 "RoyalBlue2" 21 55 55 255)
(tty-color-define-1 "DarkSlateGrey" 22 55 95 55)
(tty-color-define-1 "DarkSlateGrey" 23 55 95 95)
(tty-color-define-1 "SteelBlue4" 24 55 95 135)
(tty-color-define-1 "RoyalBlue3" 25 55 95 175)
(tty-color-define-1 "RoyalBlue3" 26 55 95 215)
(tty-color-define-1 "RoyalBlue2" 27 55 95 255)
(tty-color-define-1 "ForestGreen" 28 55 135 55)
(tty-color-define-1 "SeaGreen4" 29 55 135 95)
(tty-color-define-1 "aquamarine4" 30 55 135 135)
(tty-color-define-1 "SteelBlue" 31 55 135 175)
(tty-color-define-1 "SteelBlue3" 32 55 135 215)
(tty-color-define-1 "RoyalBlue1" 33 55 135 255)
(tty-color-define-1 "LimeGreen" 34 55 175 55)
(tty-color-define-1 "MediumSeaGreen" 35 55 175 95)
(tty-color-define-1 "MediumSeaGreen" 36 55 175 135)
(tty-color-define-1 "LightSeaGreen" 37 55 175 175)
(tty-color-define-1 "SteelBlue3" 38 55 175 215)
(tty-color-define-1 "DodgerBlue1" 39 55 175 255)
(tty-color-define-1 "LimeGreen" 40 55 215 55)
(tty-color-define-1 "SeaGreen3" 41 55 215 95)
(tty-color-define-1 "SeaGreen3" 42 55 215 135)
(tty-color-define-1 "MediumTurquoise" 43 55 215 175)
(tty-color-define-1 "turquoise" 44 55 215 215)
(tty-color-define-1 "turquoise" 45 55 215 255)
(tty-color-define-1 "LimeGreen" 46 55 255 55)
(tty-color-define-1 "SeaGreen2" 47 55 255 95)
(tty-color-define-1 "SeaGreen2" 48 55 255 135)
(tty-color-define-1 "SeaGreen1" 49 55 255 175)
(tty-color-define-1 "turquoise" 50 55 255 215)
(tty-color-define-1 "cyan1" 51 55 255 255)
(tty-color-define-1 "grey27" 52 95 55 55)
(tty-color-define-1 "grey32" 53 95 55 95)
(tty-color-define-1 "MediumPurple4" 54 95 55 135)
(tty-color-define-1 "MediumPurple4" 55 95 55 175)
(tty-color-define-1 "purple3" 56 95 55 215)
(tty-color-define-1 "BlueViolet" 57 95 55 255)
(tty-color-define-1 "DarkOliveGreen" 58 95 95 55)
(tty-color-define-1 "grey37" 59 95 95 95)
(tty-color-define-1 "MediumPurple4" 60 95 95 135)
(tty-color-define-1 "SlateBlue3" 61 95 95 175)
(tty-color-define-1 "SlateBlue3" 62 95 95 215)
(tty-color-define-1 "RoyalBlue1" 63 95 95 255)
(tty-color-define-1 "DarkOliveGreen4" 64 95 135 55)
(tty-color-define-1 "DarkSeaGreen4" 65 95 135 95)
(tty-color-define-1 "PaleTurquoise4" 66 95 135 135)
(tty-color-define-1 "SteelBlue" 67 95 135 175)
(tty-color-define-1 "SteelBlue3" 68 95 135 215)
(tty-color-define-1 "CornflowerBlue" 69 95 135 255)
(tty-color-define-1 "DarkOliveGreen4" 70 95 175 55)
(tty-color-define-1 "DarkSeaGreen4" 71 95 175 95)
(tty-color-define-1 "CadetBlue" 72 95 175 135)
(tty-color-define-1 "CadetBlue" 73 95 175 175)
(tty-color-define-1 "SkyBlue3" 74 95 175 215)
(tty-color-define-1 "SteelBlue1" 75 95 175 255)
(tty-color-define-1 "LimeGreen" 76 95 215 55)
(tty-color-define-1 "PaleGreen3" 77 95 215 95)
(tty-color-define-1 "SeaGreen3" 78 95 215 135)
(tty-color-define-1 "aquamarine3" 79 95 215 175)
(tty-color-define-1 "MediumTurquoise" 80 95 215 215)
(tty-color-define-1 "SteelBlue1" 81 95 215 255)
(tty-color-define-1 "chartreuse2" 82 95 255 55)
(tty-color-define-1 "SeaGreen2" 83 95 255 95)
(tty-color-define-1 "SeaGreen1" 84 95 255 135)
(tty-color-define-1 "SeaGreen1" 85 95 255 175)
(tty-color-define-1 "aquamarine1" 86 95 255 215)
(tty-color-define-1 "DarkSlateGray2" 87 95 255 255)
(tty-color-define-1 "IndianRed4" 88 135 55 55)
(tty-color-define-1 "HotPink4" 89 135 55 95)
(tty-color-define-1 "MediumOrchid4" 90 135 55 135)
(tty-color-define-1 "DarkOrchid" 91 135 55 175)
(tty-color-define-1 "BlueViolet" 92 135 55 215)
(tty-color-define-1 "purple1" 93 135 55 255)
(tty-color-define-1 "tan4" 94 135 95 55)
(tty-color-define-1 "LightPink4" 95 135 95 95)
(tty-color-define-1 "plum4" 96 135 95 135)
(tty-color-define-1 "MediumPurple3" 97 135 95 175)
(tty-color-define-1 "MediumPurple3" 98 135 95 215)
(tty-color-define-1 "SlateBlue1" 99 135 95 255)
(tty-color-define-1 "LightGoldenrod4" 100 135 135 55)
(tty-color-define-1 "wheat4" 101 135 135 95)
(tty-color-define-1 "grey53" 102 135 135 135)
(tty-color-define-1 "LightSlateGrey" 103 135 135 175)
(tty-color-define-1 "MediumPurple" 104 135 135 215)
(tty-color-define-1 "LightSlateBlue" 105 135 135 255)
(tty-color-define-1 "OliveDrab3" 106 135 175 55)
(tty-color-define-1 "DarkOliveGreen3" 107 135 175 95)
(tty-color-define-1 "DarkSeaGreen" 108 135 175 135)
(tty-color-define-1 "LightSkyBlue3" 109 135 175 175)
(tty-color-define-1 "LightSkyBlue3" 110 135 175 215)
(tty-color-define-1 "SkyBlue2" 111 135 175 255)
(tty-color-define-1 "OliveDrab3" 112 135 215 55)
(tty-color-define-1 "DarkOliveGreen3" 113 135 215 95)
(tty-color-define-1 "PaleGreen3" 114 135 215 135)
(tty-color-define-1 "DarkSeaGreen3" 115 135 215 175)
(tty-color-define-1 "DarkSlateGray3" 116 135 215 215)
(tty-color-define-1 "SkyBlue1" 117 135 215 255)
(tty-color-define-1 "GreenYellow" 118 135 255 55)
(tty-color-define-1 "LightGreen" 119 135 255 95)
(tty-color-define-1 "LightGreen" 120 135 255 135)
(tty-color-define-1 "PaleGreen1" 121 135 255 175)
(tty-color-define-1 "aquamarine1" 122 135 255 215)
(tty-color-define-1 "DarkSlateGray1" 123 135 255 255)
(tty-color-define-1 "brown" 124 175 55 55)
(tty-color-define-1 "maroon" 125 175 55 95)
(tty-color-define-1 "VioletRed3" 126 175 55 135)
(tty-color-define-1 "DarkOrchid" 127 175 55 175)
(tty-color-define-1 "DarkOrchid2" 128 175 55 215)
(tty-color-define-1 "DarkOrchid1" 129 175 55 255)
(tty-color-define-1 "sienna" 130 175 95 55)
(tty-color-define-1 "IndianRed" 131 175 95 95)
(tty-color-define-1 "HotPink3" 132 175 95 135)
(tty-color-define-1 "MediumOrchid3" 133 175 95 175)
(tty-color-define-1 "MediumOrchid" 134 175 95 215)
(tty-color-define-1 "MediumPurple2" 135 175 95 255)
(tty-color-define-1 "tan3" 136 175 135 55)
(tty-color-define-1 "LightSalmon3" 137 175 135 95)
(tty-color-define-1 "RosyBrown" 138 175 135 135)
(tty-color-define-1 "grey63" 139 175 135 175)
(tty-color-define-1 "MediumPurple2" 140 175 135 215)
(tty-color-define-1 "MediumPurple1" 141 175 135 255)
(tty-color-define-1 "OliveDrab3" 142 175 175 55)
(tty-color-define-1 "DarkKhaki" 143 175 175 95)
(tty-color-define-1 "NavajoWhite3" 144 175 175 135)
(tty-color-define-1 "grey69" 145 175 175 175)
(tty-color-define-1 "LightSteelBlue3" 146 175 175 215)
(tty-color-define-1 "LightSteelBlue" 147 175 175 255)
(tty-color-define-1 "OliveDrab2" 148 175 215 55)
(tty-color-define-1 "DarkOliveGreen3" 149 175 215 95)
(tty-color-define-1 "DarkSeaGreen3" 150 175 215 135)
(tty-color-define-1 "DarkSeaGreen2" 151 175 215 175)
(tty-color-define-1 "LightCyan3" 152 175 215 215)
(tty-color-define-1 "LightSkyBlue1" 153 175 215 255)
(tty-color-define-1 "GreenYellow" 154 175 255 55)
(tty-color-define-1 "DarkOliveGreen2" 155 175 255 95)
(tty-color-define-1 "PaleGreen1" 156 175 255 135)
(tty-color-define-1 "DarkSeaGreen2" 157 175 255 175)
(tty-color-define-1 "DarkSeaGreen1" 158 175 255 215)
(tty-color-define-1 "PaleTurquoise1" 159 175 255 255)
(tty-color-define-1 "brown3" 160 215 55 55)
(tty-color-define-1 "VioletRed3" 161 215 55 95)
(tty-color-define-1 "VioletRed3" 162 215 55 135)
(tty-color-define-1 "maroon2" 163 215 55 175)
(tty-color-define-1 "MediumOrchid" 164 215 55 215)
(tty-color-define-1 "DarkOrchid1" 165 215 55 255)
(tty-color-define-1 "sienna3" 166 215 95 55)
(tty-color-define-1 "IndianRed" 167 215 95 95)
(tty-color-define-1 "HotPink3" 168 215 95 135)
(tty-color-define-1 "HotPink2" 169 215 95 175)
(tty-color-define-1 "orchid" 170 215 95 215)
(tty-color-define-1 "MediumOrchid1" 171 215 95 255)
(tty-color-define-1 "tan3" 172 215 135 55)
(tty-color-define-1 "LightSalmon3" 173 215 135 95)
(tty-color-define-1 "LightPink3" 174 215 135 135)
(tty-color-define-1 "pink3" 175 215 135 175)
(tty-color-define-1 "plum3" 176 215 135 215)
(tty-color-define-1 "violet" 177 215 135 255)
(tty-color-define-1 "goldenrod" 178 215 175 55)
(tty-color-define-1 "LightGoldenrod3" 179 215 175 95)
(tty-color-define-1 "tan" 180 215 175 135)
(tty-color-define-1 "MistyRose3" 181 215 175 175)
(tty-color-define-1 "thistle3" 182 215 175 215)
(tty-color-define-1 "plum2" 183 215 175 255)
(tty-color-define-1 "OliveDrab2" 184 215 215 55)
(tty-color-define-1 "khaki3" 185 215 215 95)
(tty-color-define-1 "LightGoldenrod2" 186 215 215 135)
(tty-color-define-1 "LightYellow3" 187 215 215 175)
(tty-color-define-1 "grey84" 188 215 215 215)
(tty-color-define-1 "LightSteelBlue1" 189 215 215 255)
(tty-color-define-1 "OliveDrab1" 190 215 255 55)
(tty-color-define-1 "DarkOliveGreen1" 191 215 255 95)
(tty-color-define-1 "DarkOliveGreen1" 192 215 255 135)
(tty-color-define-1 "DarkSeaGreen1" 193 215 255 175)
(tty-color-define-1 "honeydew2" 194 215 255 215)
(tty-color-define-1 "LightCyan1" 195 215 255 255)
(tty-color-define-1 "firebrick1" 196 255 55 55)
(tty-color-define-1 "brown1" 197 255 55 95)
(tty-color-define-1 "VioletRed1" 198 255 55 135)
(tty-color-define-1 "maroon1" 199 255 55 175)
(tty-color-define-1 "maroon1" 200 255 55 215)
(tty-color-define-1 "magenta1" 201 255 55 255)
(tty-color-define-1 "tomato1" 202 255 95 55)
(tty-color-define-1 "IndianRed1" 203 255 95 95)
(tty-color-define-1 "IndianRed1" 204 255 95 135)
(tty-color-define-1 "HotPink" 205 255 95 175)
(tty-color-define-1 "HotPink" 206 255 95 215)
(tty-color-define-1 "MediumOrchid1" 207 255 95 255)
(tty-color-define-1 "sienna1" 208 255 135 55)
(tty-color-define-1 "salmon1" 209 255 135 95)
(tty-color-define-1 "LightCoral" 210 255 135 135)
(tty-color-define-1 "PaleVioletRed1" 211 255 135 175)
(tty-color-define-1 "orchid2" 212 255 135 215)
(tty-color-define-1 "orchid1" 213 255 135 255)
(tty-color-define-1 "goldenrod1" 214 255 175 55)
(tty-color-define-1 "SandyBrown" 215 255 175 95)
(tty-color-define-1 "LightSalmon1" 216 255 175 135)
(tty-color-define-1 "LightPink1" 217 255 175 175)
(tty-color-define-1 "pink1" 218 255 175 215)
(tty-color-define-1 "plum1" 219 255 175 255)
(tty-color-define-1 "goldenrod1" 220 255 215 55)
(tty-color-define-1 "LightGoldenrod2" 221 255 215 95)
(tty-color-define-1 "LightGoldenrod2" 222 255 215 135)
(tty-color-define-1 "NavajoWhite1" 223 255 215 175)
(tty-color-define-1 "MistyRose1" 224 255 215 215)
(tty-color-define-1 "thistle1" 225 255 215 255)
(tty-color-define-1 "yellow1" 226 255 255 55)
(tty-color-define-1 "LightGoldenrod1" 227 255 255 95)
(tty-color-define-1 "khaki1" 228 255 255 135)
(tty-color-define-1 "wheat1" 229 255 255 175)
(tty-color-define-1 "cornsilk1" 230 255 255 215)
(tty-color-define-1 "grey100" 231 255 255 255)
(tty-color-define-1 "grey3" 232 8 8 8)
(tty-color-define-1 "grey7" 233 18 18 18)
(tty-color-define-1 "grey11" 234 28 28 28)
(tty-color-define-1 "grey15" 235 38 38 38)
(tty-color-define-1 "grey19" 236 48 48 48)
(tty-color-define-1 "grey23" 237 58 58 58)
(tty-color-define-1 "grey27" 238 68 68 68)
(tty-color-define-1 "grey31" 239 78 78 78)
(tty-color-define-1 "grey35" 240 88 88 88)
(tty-color-define-1 "grey39" 241 98 98 98)
(tty-color-define-1 "grey42" 242 108 108 108)
(tty-color-define-1 "grey46" 243 118 118 118)
(tty-color-define-1 "grey50" 244 128 128 128)
(tty-color-define-1 "grey54" 245 138 138 138)
(tty-color-define-1 "grey58" 246 148 148 148)
(tty-color-define-1 "grey62" 247 158 158 158)
(tty-color-define-1 "grey66" 248 168 168 168)
(tty-color-define-1 "grey70" 249 178 178 178)
(tty-color-define-1 "grey74" 250 188 188 188)
(tty-color-define-1 "grey78" 251 198 198 198)
(tty-color-define-1 "grey82" 252 208 208 208)
(tty-color-define-1 "grey86" 253 218 218 218)
(tty-color-define-1 "grey90" 254 228 228 228)
(tty-color-define-1 "grey93" 255 238 238 238)
)
 
How I keep remembering new ways of using computers. My (computer-centric) new-optimization learning blog.

Name:
Location: Kobe, Hyogo, Japan
September 2003 / October 2003 / December 2003 / March 2004 / April 2004 / May 2004 / June 2004 / July 2004 / August 2004 / September 2004 / February 2005 / March 2005 / April 2005 / May 2005 / June 2005 / July 2005 / August 2005 / September 2005 / December 2005 / January 2006 / February 2006 / March 2006 / April 2006 /


Powered by Blogger