I run irssi in screen and I want screen to automatically blank the terminal (scrollback) after detach. I found out that screen has a command called "blanker" that can clear the screen, but I don't see a way to do it automatically after detach (whether remote or via C-a d).

migrated from stackoverflow.com Sep 29 '11 at 14:43

This question came from our site for professional and enthusiast programmers.


When you run screen, it sends (among other things) the strings defined in the terminal description for starting/stopping full-screen operation. These are ti and te (in termcap), smcup and rmcup (in terminfo).

  • When you start screen, or attach to a session, it sends ti (smcup).
  • When you stop screen, or detail from a session, it sends te (rmcup).

Depending on the terminal description, they may be used to switch xterm (and similar terminals) to/from the alternate screen. For most terminals, switching back to the normal screen from the alternate screen makes it seem as if the full-screen application had been cleared from the screen. (With xterm, you can switch back and forth using menus: the data is still there until it is cleared).

You could force screen to always use the alternate screen by

  • specifying a particular value for the term option, or
  • using the termcap/terminfo tweaks to modify the ti/te (smcup/rmcup) settings

Either way has drawbacks (because you might run screen on a different terminal type), but the latter is more likely to work since it does not interfere with the ability to use special keys (cursor- and function-keys).

If you prefer screen to use the alternate screen of the xterm-like terminal, you could add to your .screenrc file

termcapinfo xterm*|rxvt*  te=\E[?1049l:ti=\E[?1049h:

If you would rather not use the alternate screen, you could redefine te to clear the screen:

termcapinfo xterm*|rxvt*  te=\E[H\E[2J:ti=\E[H\E[2J:

Further reading:


Had the same problem with urxvt. Found the fix here:

in .Xdefaults:

urxvt*termName: rxvt-256color 

in .screenrc

term rxvt-256color

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy