Why bat does the pipes its output to less? #3026
-
I checked in htop that bat pipes the output of it to the less, Why? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Bat reads a file, determines its file type and performs syntax highlighting, line highlighting, adds line numbers, shows modification markers, wraps the content according to the terminal width, etc. In most cases, a file has more lines than the height of the terminal, so bat's output will also be too long to fit on a single terminal screen. Therefore, bat pipes its output to Which pager bat uses can be changed using the cli option |
Beta Was this translation helpful? Give feedback.
Bat reads a file, determines its file type and performs syntax highlighting, line highlighting, adds line numbers, shows modification markers, wraps the content according to the terminal width, etc. In most cases, a file has more lines than the height of the terminal, so bat's output will also be too long to fit on a single terminal screen. Therefore, bat pipes its output to
less
, which is a pager. Soless
is what provides the scrolling functionality.Which pager bat uses can be changed using the cli option
--pager
and paging behaviour, i.e. how bat decides whether to page or not, can be changed using--paging
.