5

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?

6

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 :-)

  • Huh, I wonder why. – Wilson F Sep 22 '15 at 23:45
  • Also, can you clarify, "that would be against the idea of paging", please? I'm not sure I follow. – Wilson F Sep 22 '15 at 23:45
  • Paging is by definition the ability to scroll around when something doesn't fit on the screen and this doesn't. It can be argued whether it's only for "pages" (i.e. lines) but I guess we are not there any more. – V13 Sep 22 '15 at 23:49
  • Does less support left/right scrolling? – Wilson F Sep 22 '15 at 23:52
  • 1
    Yes. When there's horizontal overflow with -S, try pressing the right arrow key or Esc-) / Esc-(. If you press h while in less it will show the help for this. – V13 Sep 22 '15 at 23:54

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.