Comments (2)
I noticed this behavior only if the BAT_PAGER
environment variable is defined.
$ echo $PAGER
less -Ln
$ echo $BAT_PAGER
less -Ln
# shows file using less
$ bat one-line-file.txt
# cats file to terminal
$ unset BAT_PAGER
$ bat one-line-file.txt
THIS IS A ONE-LINE FILE
However, if I alter the BAT_PAGER
variable so that it includes the -F
option for less
according the bat
README, ("The second option (-F) instructs less to exit immediately if the output size is smaller than the vertical size of the terminal. This is convenient for small files because you do not have to press q to quit the pager.") everything works as expected!
$ export BAT_PAGER='less -RFLn'
# cats file to terminal
$ bat one-line-file.txt
THIS IS A ONE-LINE FILE
If you want to use another pager app, you'll have to see if it supports an option similar to less -F
.
from bat.
Love the look of your WM.
Regarding the issue, @erhhung is correct. Unless asked not to, bat
will always pipe its output into the pager (which by default, is less
). less
will take up the full terminal and be interactive regardless of the number of lines except when --quit-if-one-screen
is passed to it as a command-line argument.
The code behind it is a bit complicated, but in most cases, bat
will automatically add that argument to less
. Explicitly setting bat
's pager may prevent that from happening in the following cases:
- The pager's executable is not named
less
. - The pager provided by
--pager
contains any command-line arguments (e.g.--pager="less --mouse"
) - The pager provided by
BAT_PAGER
contains any command-line arguments (e.g.export BAT_PAGER="less --mouse"
) - You have the
BAT_PAGING
environment variable set toalways
. - You have
--paging=always
provided tobat
.
Without knowing more about how bat
is configured in your environment, @Hashino, I can't tell you exactly why bat
isn't giving --quit-if-one-screen
to less
by default. If you want to give us that info, you can paste the output of bat --diagnostics
as a comment on this issue or edit it into the original comment :)
from bat.
Related Issues (20)
- Display Garbled on Windows Terminal HOT 2
- Multiple line selection
- `bat` silently quits, rather than reporting an error, if `less` is missing HOT 7
- Detect paths and highlight them if missing HOT 4
- `'rendering': Access is denied.` when trying to pipe output using pwsh HOT 3
- Whether to consider internationalization? HOT 1
- Bat outputs weird characters HOT 6
- Allow bat to replace variables on text HOT 2
- [Feature request] Add setting to enable maximum column for TSV hyghlighting HOT 2
- possibility to suppress output if stdin is empty and set header manually HOT 5
- Option to omit binary content even when writing to a file
- Syntax request: RDF 🐢 Turtle & SPARQL (*.ttl, *.ttls, etc.)
- compatibility issue with cat while piping in scripts HOT 3
- Gherkin support
- Add option to ship vendored libgit2 dependency
- Please support .debdiff files HOT 13
- Support for alternative theme file format(s) HOT 2
- Allow --line-range to count from the back of the file to act similar to "tail" HOT 1
- Bat can't find the theme, even though it's present HOT 6
- Should TOML-mapping-implemented file extension globs look like standard supported extensions? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bat.