Giter Club home page Giter Club logo

Comments (2)

erhhung avatar erhhung commented on June 7, 2024

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.

eth-p avatar eth-p commented on June 7, 2024

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 to always.
  • You have --paging=always provided to bat.

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.