Way for “less” to truncate lines and still exit after < 1 screen

lessoptions

Like many (most), I use git, which by default sends its output (for diffs, logs, etc.) to less, with the options -FRSX. The options are overrideable in .gitconfig by setting the pager to be called with overriding options. E.g.:

  pager=less -F -+S

When I set less to quit after less than one screen of output and not truncate lines (i.e. less -F -+S as in the example above), I get automatically returned to my command prompt after I run (say) a log command.

However, if I do have it chop lines (i.e. use only less -F), and any lines get truncated, then when it ends, it doesn't quit immediately, but prints END and waits for me to press Q, which is somewhat annoying.

(Note that the problematic behaviour does not happen if no lines are truncated because they are all narrower than my terminal. The problem is not occurring because it is asked to truncate the lines, but that it is actually doing so.)

Is there a way to chop lines and still exit from less automatically after less than a screen?

Best Answer

Well... that would be against the idea of paging... wouldn't it? :-)

But to answer your question: I'm pretty sure there isn't. This is from the source code of less:

/*
 * The char won't fit in the line; the line
 * is too long to print in the screen width.
 * End the line here.
 */
if (chopline || hshift > 0)  <--- you have chop lines (-S)
{
        ...
        quit_if_one_screen = FALSE;    <--- this resets -F
}

Sorry :-)