Friday, June 22, 2018

How to prevent GNU Screen from switching screens upon termination and detach

How to prevent GNU Screen from switching screens upon termination and detach


This blog post explains how to prevent GNU Screen from restoring the original terminal window contents upon a termination or a detach. The original terminal window contents is how the terminal window looked like before attaching. This is useful if a short-running command is running in Screen and you are interested in its final output.

Run this once:

(echo; echo termcapinfo * ti:te) >>~/.screenrc

Screens attached after running this wont restore the original terminal window contents.

Explanation: ti is the termcap equivalent of the terminfo entry smcup, and te is the termcap equivalent of the terminfo entry rmcup. They describe how to switch to the alternate screen and back. Setting them to empty will prevent Screen from switching to the alternate screen upon attach, and switching back to the normal screen upon termination and detach. Read more about these directives on http://chenyufei.info/blog/2011-12-15/prevent-vim-less-clear-screen-on-exit/.

Unfortunately, Screen still moves the cursor to the last line, and writes the [screen is terminating] message by scrolling down to the next line. This cant be disabled, its hardwired to the GotoPos(0, D_height - 1); call in FinitTerm() function in display.c . Printing many newlines when starting the Screen session improves the situation a bit, because it moves the cursor down.

go to link download

No comments:

Post a Comment