Every time I start screen (screen -A) or try to connect to an already running screen session (screen -Ax) my terminal is resized to 80 columns. I want to prevent screen from resizing my terminal.

I am using iTerm on Snow Leopard and my screen sessions are on a centos machine (I use bash as my shell).

2 Answers 2


Try adding this (from /etc/screenrc) to your ~/.screenrc:

# Change the xterm initialization string from is2=\E[!p\E[?3;4l\E[4l\E>
# (This fixes the "Aborted because of window size change" konsole symptoms found
#  in bug #134198)
termcapinfo xterm* 'is=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;4;6l'

You may need to change the "xterm" to match your $TERM.

The termcapinfo line sets is (ininitialization string) for any terminal with a name starting with "xterm" to a sequence of escape codes. \E represents escape and the codes are as follows:

\E[r       - set scrolling region to default (full size of window)
\E[m       - reset all resources (keyboard) to their initial values
\E[2J      - Erase in Display (ED). 2 -> Erase All.
\E[H       - set cursor position to default (1, 1)
\E[?7h     - DEC Private Mode Set. 7 -> Wraparound Mode
\E[?1;4;6l - DEC Private Mode Reset. 1 -> Normal Cursor Keys; 4  -> Jump (Fast) Scroll; 6 -> Normal Cursor Mode

The replaced line had these codes:

\E[!p      - Soft terminal reset
\E[?3;4l   - DEC Private Mode Reset. 3 -> 80 Column Mode; 4 -> Jump (Fast) Scroll
\E[4l      - Reset Mode. 4 -> Replace Mode
\E>        - Normal keypad

(source: XTerm Control Sequences)


The explanation (and suggested equivalents) for the xterm initialization string aren't completely accurate.

Starting with the string from xterm's terminal description:


we have

CSI ! p   Soft terminal reset (DECSTR).
CSI ? Pm l
      DEC Private Mode Reset (DECRST).
        Ps = 3  -> 80 Column Mode (DECCOLM).
        Ps = 4  -> Jump (Fast) Scroll (DECSCLM).
CSI Pm l  Reset Mode (RM).
        Ps = 4  -> Replace Mode (IRM).
ESC >     Normal Keypad (DECKPNM).

But DECSTR resets several things not found in the replacement:

  • the cursor shape and appearance
  • character sets
  • other keyboard modes related to application/normal modes (DECCKM, KAM, DECKPAM)
  • wraparound (and reverse wraparound)
  • origin mode

Also, it doesn't clear the screen.

The reason for using DECSTR (since 1997) is to keep termcap sizes small enough to fit in termcap's 1024-byte limit.

The setting for screen is from the Debian package; the bug report mentioned in the comment is Debian #134198 — screen: has some sort of odd emulation problem most noticable with irssi and konsole, from 2002. screen does not recognize that sequence, and incidentally, KDE konsole does not implement that sequence, as seen in KDE #134892, while at the same time its developers state in KDE #145977 that they prefer to not use a different TERM value than xterm. Since some users might want a terminal description which does match konsole's capabilities, that's in ncurses as konsole, e.g.,




Removing the spurious clear-screen, the relevant portion of screen's customization is


so what was left out was (aside from DECCOLM) \E[4l.

The \E7 and \E8 in the initialization string save/restore the cursor position when adjusting the scrolling margins. Just like the insert-mode, some users would notice the absence of the feature.

The point of the customization is to suppress the DECCOLM (80/132 column) switching, and working from screen's cut-down and rather old customization might not work as well as adapting from a terminal description written for the terminal.

Further reading:

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .