bat
bat copied to clipboard
Disable bolding
bat seems to bold all text by default. This makes it hard to read (at least for some people.) It would be great to have a switch to disable that.
(BTW thank you for producing this excellent tool!).
It might be worth trying with a different theme, I don't think everything generally gets bolded by default. Perhaps you see this behavior for a specific syntax being highlighted and can share an example file?
Sure. Here's the code, and a screenshot. You can see that cat and bat --theme ansi don't bold, but regular bat does. Perhaps it's not called "bold" but rather "intense" or another term.
$ ll /usr | cat
total 124K
drwxr-xr-x 12 root root 4.0K Apr 23 2024 ./
drwxr-xr-x 32 root root 4.0K May 14 09:34 ../
drwxr-xr-x 2 root root 56K May 1 13:13 bin/
drwxr-xr-x 2 root root 4.0K Apr 22 2024 games/
drwxr-xr-x 37 root root 16K Apr 28 04:49 include/
drwxr-xr-x 62 root root 4.0K Apr 28 04:49 lib/
drwxr-xr-x 2 root root 4.0K Mar 26 15:05 lib64/
drwxr-xr-x 8 root root 4.0K May 2 2024 libexec/
drwxr-xr-x 10 root root 4.0K Mar 30 19:06 local/
drwxr-xr-x 2 root root 12K May 1 13:13 sbin/
drwxr-xr-x 150 root root 4.0K Apr 28 04:49 share/
drwxr-xr-x 3 root root 4.0K May 2 2024 src/
$ ll /usr | bat
──┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ STDIN
──┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ total 124K
│ drwxr-xr-x 12 root root 4.0K Apr 23 2024 ./
│ drwxr-xr-x 32 root root 4.0K May 14 09:34 ../
│ drwxr-xr-x 2 root root 56K May 1 13:13 bin/
│ drwxr-xr-x 2 root root 4.0K Apr 22 2024 games/
│ drwxr-xr-x 37 root root 16K Apr 28 04:49 include/
│ drwxr-xr-x 62 root root 4.0K Apr 28 04:49 lib/
│ drwxr-xr-x 2 root root 4.0K Mar 26 15:05 lib64/
│ drwxr-xr-x 8 root root 4.0K May 2 2024 libexec/
│ drwxr-xr-x 10 root root 4.0K Mar 30 19:06 local/
│ drwxr-xr-x 2 root root 12K May 1 13:13 sbin/
│ drwxr-xr-x 150 root root 4.0K Apr 28 04:49 share/
│ drwxr-xr-x 3 root root 4.0K May 2 2024 src/
──┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
$ ll /usr | bat --theme ansi
──┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ STDIN
──┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ total 124K
│ drwxr-xr-x 12 root root 4.0K Apr 23 2024 ./
│ drwxr-xr-x 32 root root 4.0K May 14 09:34 ../
│ drwxr-xr-x 2 root root 56K May 1 13:13 bin/
│ drwxr-xr-x 2 root root 4.0K Apr 22 2024 games/
│ drwxr-xr-x 37 root root 16K Apr 28 04:49 include/
│ drwxr-xr-x 62 root root 4.0K Apr 28 04:49 lib/
│ drwxr-xr-x 2 root root 4.0K Mar 26 15:05 lib64/
│ drwxr-xr-x 8 root root 4.0K May 2 2024 libexec/
│ drwxr-xr-x 10 root root 4.0K Mar 30 19:06 local/
│ drwxr-xr-x 2 root root 12K May 1 13:13 sbin/
│ drwxr-xr-x 150 root root 4.0K Apr 28 04:49 share/
│ drwxr-xr-x 3 root root 4.0K May 2 2024 src/
──┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
$
It could just be a different text color, yeah. There's a couple of things we can do to check if the bold attribute is involved, though:
-
Is it still too bright if you use
batwith--decorations=never? Bat does set the bold attribute in the header, but it won't for the plain text itself. -
Can run this to get the list of color codes being printed and let me know what shows up?
ll | bat --color=always --decorations=never --paging=never | grep -o $'\033\\[[^m]*m' | sed $'s/\033/^/g' | sort -u
- No difference:
$ ll | bat --color=always --decorations=never --paging=never | grep -o $'\033\\[[^m]*m' | sed $'s/\033/^/g' | sort -ugives:
^[0m
^[38;5;231m
Thanks for the info.
Yeah, the extra bright white is just the text color used by the theme. It's using color 231 from the 256-color palette:

I see. Is there a simple way to shut that off?
Probably to edit the theme and choose a different foreground color: https://github.com/sharkdp/bat?tab=readme-ov-file#highlighting-theme