For the last few days I’ve been fiddling around, trying to solve an annoying problem with an OpenBSD machine (running OBSD 4.1) and my Mac. Basically, what was happening is that when I connected to the OBSD box via a terminal on the Mac, using either Apple’s or the freeware iTerm, after quitting Emacs, all the text subsequently written to the terminal would have the same background color as was set in Emacs. It was as though Emacs just refused to unset the terminal’s background color on exit.

I sought help from the comp.unix.bsd.openbsd.misc newsgroup, and they didn’t let me down. I got two very helpful responses, from Thomas Dickey and Christian Weisgerber: both suggested that it was my choice of ‘xterm-color’ as a terminal type that was to blame.

Changing the TERM setting on my OBSD machine (in “.profile”) to ‘xterm-xfree86’ seemed to do the trick, and now I get a nice colorized Emacs, and it drops back cleanly into the Terminal’s defaults on exit.

Thomas Dickey also gave a link to a terminfo database that’s significantly more up to date than the default one included with OpenBSD; it’s available via FTP at his site here. However, even in his version there’s no specific termcap entry for Apple’s; the best fit still seems to be xterm-xfree86.

The one caveat of all this is that the cursor color seems to be unaffected by whatever’s specified in the “.emacs” configuration file when you connect via a remote (SSH) terminal, so it makes sense to choose an Emacs color scheme that’s similar to your terminal default (or else you may end up with a black cursor on a black background).