Comment

Comment by ventana

This 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

parent ventana 3 months ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton