Skip to content
Discussion options

You must be logged in to vote

What you are feeding into bat already contains ANSI escape sequences, so bat is trying to syntax-highlight text that is not plain text anymore. The README calls this out explicitly: ANSI/control sequences can make highlighting and wrapping look garbled.

The first thing I would try is stripping the ANSI sequences before highlighting:

batcat --strip-ansi=auto -pp test.log

If your bat version supports it and you want to be more aggressive:

batcat --strip-ansi=always -pp test.log

If the goal is to preserve the original terminal coloring rather than re-highlight it, then bat is probably the wrong stage for that file. In that case, either:

  • view it with a pager that renders raw ANSI correctly, or

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@og900aero
Comment options

Comment options

You must be logged in to vote
1 reply
@hermanmalik
Comment options

Comment options

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