The Problem:
Back in the 10.2 (?) days, this wasn't an issue -- for whatever reason (my guess being differences in the terminfo database), this alternate screen business was ignored, and one could see the work left behind by exiting programs. With Panther, and its incorporation of significant Linux influences, this behavior changed, much to my disappointment. Suddenly, one-too-many presses of the space bar and man pages were disappearing, pids that top revealed as needing to be killed were no longer visible after hitting "q" -- a whole litany of annoyances cropped up.
A solution:
I have seen various suggestions in various places regarding remedies, but none of them have been optimal. Some fixed the problem, but caused others equally irritating. Finally over Christmas, I found the time to play around a bit, and created an alternate terminfo entry for xterm-color.
What it does:
My slightly altered xterm-color has the following beneficial (at least to me) effects:
- Disables the "alternate screen buffer" so the work done by a program is left on the screen after it exits, as described above.
- Fixes an annoying problem with some other terminfo entries in which the last line of top's output is overwritten by the shell prompt upon exit.
- Allows the use of colorschemes and syntax coloring in vim without drawing insane underlines all over the place.
By replacing the
xterm-color entry in the terminfo database, we can alter the capabilities which tell programs the character sequences
to send to the Terminal to begin and end the use of the alternate screen buffer. If we then tell Terminal to use our new terminfo entry, its xterm-color emulation will take on the behavior specified by the altered entry. In the replaced entry, only the smcup and rmcup capabilities have been changed; it is otherwise exactly the same as Apple's xterm-color which shipped with Panther.
How to install it:
- Download the compiled terminfo description file. The source is also included, so if you're paranoid, you can compile it yourself. Doing so isn't that hard, but requires a little work which is beyond the scope of this hint.
- In a Terminal window, cd to /usr/share/terminfo, and do a find . -name xterm-color. If your system is the same as mine, you should see this:
If not, replace 78 in the following with whatever directory your xterm-color entry was in../78/xterm-color - Make a backup copy prior to replacing:
Obviously, use whatever name you want for the backup.$ cd 78 $ sudo cp xterm-color xterm-color.apple - Move or copy your downloaded xterm-color (in the archive's compiled directory) into place. You'll probably want to use sudo again, and set the ownership and permissions to correspond with those of the other files in the directory.
If you decide you don't like it, just replace the downloaded xterm-color with your backup copy.
Disclaimer:
As you might guess, there are several other ways in which similar effects can be achieved. The one I have decided to implement may be less than optimal depending on your needs or philosophy, but it fits mine. This hint is offered in the hopes that others may find it useful, and does not pretend to be the "best" or even the only solution.
[robg adds: This hint describes (in the hint and comments) a couple of other ways of working around the problem; between these two hints, there should be a solution for everyone. I've personally just set the terminal type to VT100, though that leaves me with the "last line overwrite" problem in top described above...]

