4
votes

In a regular bash session if I type vi, or emacs -nw and then I exit or suspend them, I return to my shell unscathed (with the previous couple commands I had typed still visible). The shell is intact as If I had never launched emacs or vi. When using GNU Screen, however, after exiting I still see vi/emacs with whatever I was doing, forcing me to use screen scroll or history to recall even the last command I had run before launching emacs/vi. How do I toggle this cluttering behavior off? Is it possible?

2

2 Answers

5
votes

The unscathed aspect is because vi/emacs is using your terminal's alternate screen for curses (the library that lets them put characters in arbitrary positions on the terminal screen). screen(1) the program is already using the alternate terminal screen, and doesn't, by default, create an alternate screen of its own for programs run inside of it to access via curses.

However, you can enable it in screen with:

   altscreen on

in your ~/.screenrc file.

See the screen manpage for more info.

5
votes

You need to switch on support for alternate screen.

You can do this by adding the following line to your .screenrc:

altscreen on

Source: http://aperiodic.net/screen/commands:altscreen