After quitting elinks, the browser page history is lingering in my scrollback buffer, and therefore not returning to whatever was buffered on screen when I launched elinks.

Inside a GNU screen with altscreen enabled, this does not happen. But in any normal terminal session elinks stays in the buffer. I note that other terminal programs like Vim and lynx do not stay in the scrollback buffer, and instead return the buffer to its state at the time they were launched. I am not finding a configuration option in ELinks to ensure it switches to the alternate terminal, however.


Is there a configuration option to prevent ELinks sticking around in the scrollback buffer?


On a little further investigation, the scrollback problem occurs only in iTerm2 and Terminal.app on OSX. In an XTerm, ELinks does not modify the scrollback buffer.

  • Have you tried the answers from this question? – Thor Sep 7 '12 at 15:57
  • @Thor Thanks but I'm not looking to clear the scrollback, just to prevent elinks from writing to it. – Michael Sep 7 '12 at 16:07

The apparent problem is that OP dislikes the way Terminal and iTerm2 show (or do not show) the alternate screen. That is a feature of xterm and programs which imitate it, which allows an application to display full-screen text without modifying the normal command-line text.

elinks decides to use the alternate screen if (a) it thinks it is running in xterm, or (b) if it thinks it is running in GNU screen.

  • It makes the check for "xterm" by seeing if two environment variables are set to non-empty values: DISPLAY and WINDOWID.
  • It makes the check for "GNU screen" by seeing if the STY environment is set.

Since neither condition would normally be true in Terminal or iTerm2, it seems that OP wanted to get elinks to use the scrollback buffer. Both of those programs support the feature.

The easy way would be to run GNU screen, since OP would immediately get the desired behavior. If that is not possible, one could pretend to be running in screen by setting the STY environment variable, while running elinks (which has fewer side-effects than trying to pretend it is running in xterm).

Since having that variable set at random would interfere with running GNU screen, it would work best as an alias, e.g.,

alias elinks='STY=fixup /opt/local/bin/elinks'

(using the pathname that MacPorts uses for the executable).

| improve this answer | |

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.