The screen contents are not restored when detaching a "screen" session. To reproduce the problem: 1. Run rxvt-unicode. 2. Run some commands, just to generate contents in the screen. 3. Run the "screen" utility. 4. Detach the "screen" session ([Cmd key] d), or simpler: terminate the shell (this will close the session and quit screen). The bug: The contents one had before running "screen" are not restored. I don't have this problem with xterm, aterm or gnome-terminal.
The problem is that screen fails to enable the alternate screen buffer in urxvt. This happens because screen sends "is2" after "smcup", and is2 disables the alternate screen buffer. The problem does not occur in xterm because xterm's is2 does not disable the alternate screen buffer.
Thanks for the information. Isn't there any standard about is2? Is it a bug in rxvt-unicode, ncurses-base (which provides /lib/terminfo/r/rxvt-unicode, but perhaps following recommendations by rxvt-unicode developers) or screen (which sends "is2")? Even if one considers that screen does something bad and should be fixed, the incompatibility between rxvt-unicode and other terminals (xterm, gnome-terminal) can be annoying.
Marc changed is2 in 9.06 with the following rationale "redundantly clear mouse reporting and a few other states in tput init/tput reset, for older urxvts" but I cannot remember what exactly prompted this change.
Well, the terminfo manpage says it initialises the terminal, and that is2 usually does most of that work, but that doesn't matter, as they are all taken together (there are multiple ones so you can split very long init sequences, there is no semantic difference between is1, is2 etc.). Almost certainly screen - ncurses programs do the right thing and don't reset the terminal *after* configuring it. I don't know what screen tries to accomplish, but if it wants a clean state, then it needs to output all the intiialisation sequences *before* configuring the terminal, as obviously configuration can be lost when intiialisaing the terminal. And if screen outputs is2 but not the other sequences as required by terminfo, that's an even bigger wtf. There is no reason to do so, and that *will* break things. Hmm, which incompatibility is there? "tput init" is the canonical way to bring your terminal into a clean state after a curses program (or screen, which loves to crash...) crashed. The change just implemented that.
screen doesn't reset the terminal after configuring it. This can be seen with xterm and gnome-terminal. Perhaps. It seems to make sense. However the terminfo(5) man page doesn't document that it should be done in this order. I don't know what screen does exactly, but tput smcup tput init tput rmcup works in xterm, but not in rxvt-unicode. This may be the problem with screen. See above. Unless the above sequence is incorrect... No, this is "tput reset" that brings the terminal into a clean state. "tput init" doesn't do that in at least two major terminals: xterm and gnome-terminal.
Hello! In Debian 9 terminal content is not restored even in xterm. I work around the problem with the following trick: In .screenrc I completely removed ti/te: termcapinfo xterm*|rxvt* 'ti=:te=' I run screen wrapped with tput calls: tput smcup; screen -S test; tput rmcup This works quite good except for commands that make screen to write to terminal like -ls or -Q: the final tput hides the text. So I wrote a screen wrapper in shell: #! /bin/sh if [ "$1" = "-ls" -o "$1" = "--list" ]; then list=true fi test "$list" = true || tput smcup /usr/bin/screen "$@" test "$list" = true || tput rmcup Now it's near perfect. Tested with rxvt and xterm. Oleg.
This will hide error messages. For instance: $ tput smcup; screen -r does_not_exist; tput rmcup
Control: found -1 4.8.0-6 Control: found -1 4.9.0-4 Control: found -1 4.9.1-1 The bug no longer occurs in rxvt-unicode 9.31-3 from Debian/unstable, but it still occurs in rxvt-unicode 9.30-2 from Debian 12 (stable).
Actually it still occurs in rxvt-unicode 9.31-3 from Debian/unstable. I might have done something wrong.
Control: forwarded -1 https://savannah.gnu.org/bugs/?65506 and I've just reported the bug upstream (GNU Screen).