Let less work like cat, if only one screen full of text

catlesspager

On my Debian machine here, less always opens the alternate screen to show stuff.

This is annoying, if there are only 2 or 3 lines to be displayed. I'd like less to:

  • work as pager, if there is more than a screenful of information

  • and work like cat, if there's not.

Apparently, less has the -F flag for "single screen" cases:

-F or –quit-if-one-screen

Causes less to automatically exit if the entire file can be displayed on the first screen.

But in my case it just exits again, and no info is displayed. It's more like cat /dev/null and thus not really useful.

Has anyone an idea, how to achieve this less behaviour?

Best Answer

You can combine -F with -X, which disables the terminfo initialization sequence.

export LESS=-FX

This has the (dis)advantage that less does not clear displayed text on exit, no matter how long the file was.

Related Question