6 ms·
> Use a pager (e.g. less) if you are outputting a lot of text. If I wanted to use a pager I'd pipe the output to a pager, no pipe to pager means I want it all
by eikenberry 3mo ago
> Use a pager (e.g. less) if you are outputting a lot of text.
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.
- keithnz 3mo ago100% - I want to use whatever pager I might prefer at the moment, this advice violates their core principle "you make programs that are modular enough to be recombined as needed"
- oneeyedpigeon 3mo agoI find it far more convenient for tools to take options to use a pager, rather than to having to manually type "| less" for every command that I want to behave nicely. Just behave nicely by default; if I want you to behave awkwardly, I'll let you know!
- chriswarbo 3mo agoDefine "nicely". 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)
- ventana 3mo agoThis is a common approach, CLI tools often use isatty [1] to check if the output fd is a TTY or not. Try running "git log" for example; if you have many commits, it will page through "less" or $PAGER only if it sees that you're on a real TTY; but if not, it will not. Try this: 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". [1]: https://man7.org/linux/man-pages/man3/isatty.3.html https://man7.org/linux/man-pages/man3/isatty.3.html
- jpitz 3mo agoI'm bothered by it because whatever git command that I'm executing will put its output in a pager and when I quit the pager it's not there anymore. I want the output on the screen when I start typing the next command. Oh my God, this is such a frustrating pattern.
- ventana 3mo agoThen export PAGER= in your shell profile should help!
- Ferret7446 3mo agoUnfortunately not all programs respect an empty PAGER vs an unset PAGER. It's more reliable to use PAGER=cat
- simon-b 3mo agoThis is indeed an annoying, but solvable, less default. You can eg use `export LESS="-XF"` to change behaviour.
- asabla 3mo agoIt took me way too many years before I set this as a default in my profile files. 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
- jpitz 3mo agoThat's useful, although I don't know if I will enable it for generally or specifically for git.
- Vingdoloras 3mo agoI had the same issue specifically with git, for the same reason. You can configure git to not use a pager by setting core.pager to an empty string.
- 3mo ago