Prevent unwanted Terminal screen clearing

In Terminal, some Unix programs, particularly vi and man, will clear the screen when you quit them. I understand the aesthetic; leaving a clean screen is neater than leaving it littered with text. However, what if you had a man page open to just that one important bit you wanted to see while typing out the command?

There are a number of ways to fix this, but here’s the simplest: open Terminal’s preferences, and set the ‘Declare terminal type ($TERM) as’ pop-up to either ansi or vt102 (vt52 and vt100 work as well). Open a new Terminal window and then test your settings—type man bash for instance, press the Space Bar a couple times to page down into the document, then press Q to quit. The last page you were viewing should remain on your screen.

Note for the Unix wizards: Technically, I realize that this isn’t the “right” way to fix this problem. The problem, at least for the man command, is that the less pager is sending the screen clearing instructions when you press Q. You can fix this by editing your .bashrc (or whatever startup file you use) and including a line that reads export LESS=X. However, since this only changes the behavior of less, you’ll still have the screen clearing problem in vi. Changing the terminal type, however, seems to fix the issue everywhere.

  
Shop Tech Products at Amazon