I've been using less forever now, and there's one thing I wish it was doing differently.

When I do git log --pretty=oneline --abbrev-commit it switches to full-screen immediately (as the output is very long), while 99% of the time I only care about first 5 commits or so. Sure I can do git log --pretty=oneline --abbrev-commit | head -n 5, but that's extra work that I would like to avoid.

Ideally, I'd like the pager to display N first lines first without clearing the screen and taking over. If I press q, it should just exit and leave that 5 lines there. If I press space (or whatever) only then it should switch to full-screen, like it normally does. less -F works a little it like that, but not exactly. I would like avoid jumping to full-screen on long output.

I don't see any way to script this-out. Is there any alternative pager that can or a way to achieve it with less?

1 Answer 1


If you want just 5 lines of the git log, then just use the git's own key:

git log --pretty=oneline --abbrev-commit -n5

The -n key for log command is designed specifically for that.

Running git log --pretty=oneline --abbrev-commit | head -n 5 removes the requirement of the pager. The head will just send data to TTY while stripping all escape sequences (meaning no color).

If you interested in other options, not git related. Then you can look at terminals which are able to split its screen like tmux or gnu screen. Split terminal window, you have now two shells in one window - run in one shell your standard pager, in another something else. It would be effectively two (or more) consoles, but from Window Manager point of view it would still be one window with one maximize-minimize-close set of buttons.

Emacs and vim also able to do a split screen with giving one section to shell, and another for some text.

There is a pager most which is able to split screen and show several different files at the same time. Looks a lot like vim but without editing.

  • I'm aware of all of this, and it is not what I'm looking for. Thanks anyway.
    – dpc.pw
    Feb 23 at 23:35

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.