gnome-terminal clear screen on program exit

You know how programs like ‘less’, ‘vim’ and apparently ‘mutt’ and others clear the screen when you exit or suspend them? To some, it’s a feature. To others, myself included, it’s an abomination. Ptang Ptang Olay Biscuit Barrel posted animations that demonstrate the wrong way and the right way for terminals to behave.

If you’re using xterm, you can disable this by adding “XTerm*titeInhibit: true” to your .Xresources file. There are simple ways to fix this in most terminal programs I’ve looked up. The one exception: gnome-terminal.

I won’t speculate as to why gnome-terminal, or more specifically, libvte does not offer a way to disable the “alternate screen” functionality. Instead, I just hacked the code up a little. This is a really brute hack (not user-configurable, just a dumb if (0) here and NULL there), and I’m not particularly proud of it, except that I think it might be the first public attempt to resolve this issue at the source. I can’t guarantee these will work for you, of course, but they do work for me. They are Debian packages built on an etch system.

libvte-common_0.12.2-5-dpk1_all.deb
libvte4_0.12.2-5-dpk1_i386.deb

The technical details: What I did was make it so 47, 1047, and 1049 “codes” would not swap between the alternate and the primary terminals. Then I commented out all of the code in 47, 1047, and 1049 and put in a call to vte_sequence_handler_ll which scrolls to the end. Here’s the diff. If one is so inclined, it would be neat to make it an option configurable via gconf, or whatever configuration method is used for vte or gnome-terminal these days. I’m not so inclined because I cannot imagine a scenario in which I would ever want the screen to clear when I suspend a man page or vi.

4 Comments

  1. rone says:

    So explain to me why you’d use gnome-terminal instead of good ol’ xterm (or another sane terminal program).

  2. dpk says:

    There was once a time in the past where I was using xterm and found it to be much faster than gnome-terminal. However recent tests on newer hardware have had opposite results, so I decided to give it a chance.

    Clickable URLs are kind of neat.

  3. rone says:

    You were always a sucker for the clicky… i knew it.

  4. Anti-DPK says:

    I love you rone.

Leave a Reply