Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid emacs (or vi) remaining on your screen after closing when using GNU screen?

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?

like image 541
Palace Chan Avatar asked Dec 28 '22 03:12

Palace Chan


1 Answers

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.

like image 145
Alex North-Keys Avatar answered Jan 13 '23 15:01

Alex North-Keys