If I wanted to use a pager I'd pipe the output to a pager, no pipe to pager means I want it all dumped to STDOUT. So annoying.
If I wanted to use a pager I'd pipe the output to a pager, no pipe to pager means I want it all dumped to STDOUT. So annoying.
git log # PAGER undefined; uses less
PAGER=/usr/bin/head git log # pages through head, you get 10 lines
PAGER= git log # PAGER is empty; does not page
git log | cat # output is not a TTY; does not page
(also, notice that git uses colors if the output is going to a terminal, and does not if not)I don't think I was ever bothered by the automatic paging through "less".
The funny thing is. I kept missing this detail every time I read through git. Feels like I was blind to the whole concept of it
I want the output visible on screen after I exit the pager. If I didn't want it on screen, I'd pipe it to a file and open that in a text editor. That will disappear when I close the file. As a bonus: I can then use grep without having to repeat whatever command I used.
Even more importantly: I want the command to behave identically regardless of whether its stdin or stdout is /dev/null or a terminal or a socket or a serial port or a pipe or anything else that it can read or write with. Try writing a script when the tools themselves change how they behave whether they're running in a script or in a terminal or elsewhere. It kinda sucks.
But we smart coders. We think everything. Remind me later.
_less_ has a nice "&" command that is like "/" (search) but that filters instead like grep.
You can also pipe to an external command from less
For example, many pagers don't work well when stdin is line-buffered (they assume they'll see individual key presses as they happen)
Pagers can also conflict with keys that the terminal emulator is using for a different purpose. This is especially annoying when the terminal emulator is using those keys for pager-like functionality in the first place!
An example of both of these is Emacs `shell-mode`.
(I personally set `PAGER=cat` in my Bash profile, which avoids most of these shenanigans)