Skip to content

Why bat does the pipes its output to less? #3026

Discussion options

You must be logged in to vote

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. So less 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.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by eth-p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants