How to Restore PuTTY Scrollback Buffer Functionality When Using GNU Screen


2 views

Many developers encounter this frustrating scenario: you're working in a PuTTY session, launch GNU Screen, and suddenly your mouse scroll wheel can't access the terminal history. The scrollback buffer appears frozen, showing only content from before the Screen session started.

This occurs because GNU Screen creates a virtual terminal that doesn't propagate scroll events to PuTTY's native buffer. The terminal multiplexer maintains its own scrollback buffer internally, which requires different access methods.

While we can't make the mouse wheel work directly, here are practical solutions:

# Screen's built-in scrollback (default keybindings):
Ctrl+A then [  # Enter copy mode
Use arrow keys to scroll
Press Esc to exit

# Alternative: increase Screen's buffer size in ~/.screenrc:
defscrollback 10000  # Sets 10,000 line buffer

These adjustments can improve the experience:

1. In PuTTY Configuration:
   Window → Lines of scrollback → Set to higher value (e.g., 20000)
   Window → Behaviour → "System menu appears on ALT alone"

2. For Windows clipboard integration:
   Enable "Shift overrides application's use of mouse" in Selection

For persistent logging that survives Screen sessions:

# Create named pipe
mkfifo /tmp/term.log

# In ~/.screenrc:
logfile /tmp/term.log
logfile flush 1
log on

# In another terminal:
tail -f /tmp/term.log | less

Recent versions of GNU Screen support mouse events with:

# In ~/.screenrc:
termcapinfo xterm* ti@:te@
mousetrack on

# Then in Screen session:
Ctrl+A then :mousetrack on

For developers who need both multiplexing and scrollback:

  1. Use tmux instead of screen (better mouse integration)
  2. Configure PuTTY to log all sessions automatically
  3. Bind Screen's copy mode to accessible keys
  4. Consider using MobaXTerm for Windows with built-in features

Many developers using PuTTY with GNU Screen encounter an unexpected behavior: their scrollback buffer suddenly stops capturing terminal output after launching Screen. What you're seeing in the scrollback is actually the pre-screen session content, while Screen maintains its own separate scroll buffer.

GNU Screen operates as a terminal multiplexer, creating virtual terminals that handle their own:

  • Scrollback buffers
  • Input/output handling
  • Terminal emulation

When you enter Screen, PuTTY's native scrollback can no longer see the actual terminal output - it's being intercepted and managed by Screen itself.

Here are several approaches to regain scrollback functionality:

1. Using Screen's Internal Buffer

While not mouse-wheel compatible, Screen provides powerful buffer navigation:


# Enter copy mode (scrollback)
Ctrl-a [

# Navigation in copy mode:
Up/Down arrows - Scroll line by line
Ctrl-u/Ctrl-d - Scroll half page
Ctrl-b/Ctrl-f - Scroll full page

2. PuTTY Configuration Adjustments

Modify PuTTY's settings to better handle Screen sessions:


Window → Behavior:
☑️ Disable scrollback on alternate screen (uncheck this)
Connection → SSH:
☑️ Don't allocate a pseudo-terminal (try both states)

3. Alternative Terminal Approach

Consider using mosh (Mobile Shell) instead of SSH:


# Install mosh on both client and server
sudo apt-get install mosh

# Connect using:
mosh user@server -- screen -Rd

For critical sessions where you need both Screen and scrollback:


# Start screen with logging:
screen -L -Logfile /path/to/screenlog.%t

# Or enable logging during session:
Ctrl-a : logfile /tmp/screenlog
Ctrl-a H  # Start/stop logging

Modern terminal emulators handle this better:

  • Windows Terminal with WSL
  • KiTTY (PuTTY fork with better scrollback)
  • MobaXTerm (for Windows users)