256 Colors in Vim, inside Screen, in an iTerm, on OS X Leopard
Borrowing a lot from this sage advice, I decided it’s time to figure out 256 color vim on OS X. That meant immediately leaving Terminal.app for dead, since he can’t display more than 8 (16 w/ANSI bold) colors. Here’s the alternative I came up with:
- Installed iTerm.
- In iTerm, hit option+cmd+B for “Profiles”.
- Under “Keyboard Profiles, Global”, I removed all the mappings and set the “Option Key as” to “+Esc”. This allows me to switch channels in irssi with option+number.
- Under “Terminal Profiles, Default”, I changed “Type” to “xterm-256color” and checked “Blinking cursor”.
- Under “Display Profiles”, for “Dark Background” and “Light Background”, I tweaked the “Cursor” colors to be more visible.
- Grabbed this perl script that prints a 256 color test palette to the console. Ran it outside of GNU Screen, and everything looked good.
- Added the following lines to my ~/.screenrc:
> #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
> # the first two are for other terminal emulators, just in case.
> termcapinfo xterm “Co#256:AB=E[48;5;%dm:AF=E[38;5;%dm”
> termcapinfo xterm-color “Co#256:AB=E[48;5;%dm:AF=E[38;5;%dm”
> termcapinfo xterm-256color “Co#256:AB=E[48;5;%dm:AF=E[38;5;%dm”
> term xterm-256color
> # erase background with current bg color
> defbce “on” - Ran the test script inside of GNU Screen, everything looked good.
- Added the following lines to the top of my ~/.vimrc, because apparently “set t_Co=256” must appear before any syntax and color settings:
> set t_Co=256
> :colorscheme railscasts - Started up vim inside GNU Screen, and voila!
- Wrote about it here so I never forget this stuff.