I'm tweaking the pager of Git, but I've got some issues with it.
What I want is:
- Always colored output
- Scrolling by touchpad or mouse
- Quit-if-one-screen
And my current configuration is:
$ git config --global core.pager
less -+F -+X -+S
This does everything except the last one.
But, if I remove -+F
, there will be no output in case of one-screen. If I remove -+X
as well, the output is back but I cannot scroll by touchpad in less
.
Is there a workaround which can meet all the requirements above?
Best Answer
UPDATE
tl;dr Solution: upgrade to less 530
From http://www.greenwoodsoftware.com/less/news.530.html:
So with this fix we don't even need to bother determining whether to use
-X
on our own,less -F
just takes care of it.PS. Some other less configs that I use:
I eventually ended up with writing a wrapper on my own.
BSD/OSX users should manually install
gnu-sed
. The amazing regexp, which helps remove color codes, is from https://stackoverflow.com/a/18000433/2487227I've saved this script to
/usr/local/bin/pager
and thengit config --global core.pager /usr/local/bin/pager
The treatment for OCD patients, hooray!