batcat (or bat) displays ANSI color codes instead of rendering the colors #3257
-
|
When I batcat this log file, I dont see colorized text. Only the color codes. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
|
Hi, it's hard to say without more details. Please can you post the log file in question and the output from |
Beta Was this translation helpful? Give feedback.
-
|
I made a test file to figure out what is going on. It appears the issue is that bat doesn't support semicolons in the ANSI sequences. Try for yourself with the following (make sure the unprintable character in the beginning of each line actually is the character '\e' or '\033'): �[0;31m REGULAR RED �[0;91m HIGH INTENSITY RED I played around with the --pager and --paging flags to make sure that it was using less with the -R flag, but it didn't help. Note that less, by itself, with the -R flag, renders all of these correctly. |
Beta Was this translation helpful? Give feedback.
-
|
What you are feeding into The first thing I would try is stripping the ANSI sequences before highlighting: batcat --strip-ansi=auto -pp test.logIf your batcat --strip-ansi=always -pp test.logIf the goal is to preserve the original terminal coloring rather than re-highlight it, then
So the short version is: this is not a normal |
Beta Was this translation helpful? Give feedback.
What you are feeding into
batalready contains ANSI escape sequences, sobatis 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:
If your
batversion supports it and you want to be more aggressive:If the goal is to preserve the original terminal coloring rather than re-highlight it, then
batis probably the wrong stage for that file. In that case, either: