In OS X terminal, when less
is called on its own or by other programs like man
, its output won't be written to the tty after we quit less
. For instance, if we run less README
, we would be temporarily directed to a screen with things like
SO rocks.
README (END)
And after pressing q
, the output of less
would disappear, and we end up with something like
$less README
$ # shell waiting for input
However, this is not the case if less
is called by git
(the pager of git
is set to less -r
in my case). The output of less
is always written to the tty after quitting. For instance, if we run git log --oneline
, if the log is short less
won't even be called; if the log is longer than one screen, then we would be temporarily directed to the output screen of less
as usual:
0000000 set the pager of git to less
......
1111111 what's wrong with git?
(END)
And after pressing q
, the whole thing gets written to the tty, so we end up with something like
$git log --oneline # OMG!!!
0000000 set the pager of git to less
...... (the entire log)
1111111 what's wrong with git?
$ # shell waiting for input
So it is possible to change this behavior? I mean, is it possible to configure git
so that it always pipes output to less (no matter the output is long or short), and leave nothing in the tty after less
is quit? Thanks.