When working with SSH sessions and GNU screen on remote Linux servers from macOS Terminal.app, users often encounter scrollback limitations. The standard macOS Terminal scroll gestures don't work as expected when nested within screen sessions.
To navigate scrollback in a screen session:
# Enter copy/scrollback mode Ctrl + a + [ # Navigation controls: Up/Down arrows - Move line by line Page Up/Down - Jump by pages Space - Page down b - Page up # Exit scrollback mode Esc or q
Increasing Scrollback Buffer
Set a larger scrollback buffer in your .screenrc
:
# Add to ~/.screenrc defscrollback 10000
Logging Output
For persistent output capture:
# Start logging Ctrl + a + H # Or log to file screen -L -Logfile /path/to/logfile.txt
For macOS Terminal users, these settings help:
# In Terminal Preferences: 1. Go to Profiles > [Your Profile] > Window 2. Set Scrollback lines to Unlimited 3. Enable "Save lines to scrollback when an app status bar is present"
When debugging a Python script that crashes with verbose output:
$ screen $ python crashy_script.py [Lots of error output] # Now to examine: Ctrl + a + [ [Scroll up to find error] q
- Use
Ctrl + a + d
to detach instead of closing terminal - Combine with
less
ortee
for critical outputs - Consider tmux as an alternative with better scrollback support
When debugging applications through SSH, we often encounter situations where:
- Error logs exceed terminal height
- Critical output disappears from view
- Standard scrolling methods fail in screen sessions
The scrollback flow works like this:
macOS Terminal.app → SSH client → Remote screen session → Application output
Method 1: Screen's Copy Mode
The most reliable approach uses GNU Screen's built-in scrollback:
1. Press Ctrl+A then Esc (enters copy mode)
2. Use arrow keys or vim-style navigation (h,j,k,l)
3. Press Esc to exit copy mode
Method 2: Terminal Buffer Configuration
Prevent future issues by increasing scrollback lines in Terminal.app:
Terminal → Preferences → Profiles → [Your Profile] → Window
Set "Scrollback lines" to 10000 or higher
Method 3: Pipe Output to Less
For immediate viewing of large outputs:
your_command 2>&1 | less -R
For critical debugging sessions, consider these approaches:
# Method A: Tee to file
your_command 2>&1 | tee debug.log
# Method B: Script command
script debug.session
your_command
exit
- Ensure $TERM is set correctly (usually xterm-256color)
- Verify screen version:
screen -v
- Check for terminal emulator limitations