Git Product home page Git Product logo

Comments (2)

Ballasi avatar Ballasi commented on August 18, 2024 2

I feel like there would be no use for us to redirect to a variable other than for instance redirecting to a file (or directly do ./xdg-ninja.sh > output).

It is unlikely to do so but plausible, I would by myself disable this BUT, in this case, the rest of the program forces coloration (e.g., XDG env variables warning), so it makes sense to force bat to do so.

I think replacing -f to --decorations=always --color=always is what is best in that case, and that if there is a need for file redirection in the future, it would be best to add a --disable-color argument in the command.

from xdg-ninja.

pvonmoradi avatar pvonmoradi commented on August 18, 2024

Since at that point of the code, the output is being printed directly to an interactive tty, bat uses colorization. However, if the code is changed into this:

a=$(printf "%s\n" "$HELP" | bat -pp --language markdown)
printf "%s" "$a"

Then colorization is deactivated cause -f is not provided.
To accomodate for older versions of bat, we can use --decorations=always --color=always in place of -f. Either that, or we can remove this switch altogether but remember to not redirect printf | bat to anything other than an interactive tty.

bat's manpage:

       -f, --force-colorization

              Alias for '--decorations=always --color=always'. This is useful if
              the  output  of  bat  is piped to another program, but you want to
              keep the colorization/decorations.

from xdg-ninja.

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.