bat icon indicating copy to clipboard operation
bat copied to clipboard

Disable bolding

Open Taylor-C-Reese opened this issue 6 months ago • 7 comments
trafficstars

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!).

Taylor-C-Reese avatar May 06 '25 20:05 Taylor-C-Reese

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?

keith-hall avatar May 14 '25 02:05 keith-hall

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.

Image

Image

$ 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/
──┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
$

Taylor-C-Reese avatar May 14 '25 13:05 Taylor-C-Reese

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:

  1. Is it still too bright if you use bat with --decorations=never? Bat does set the bold attribute in the header, but it won't for the plain text itself.

  2. 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

eth-p avatar May 14 '25 16:05 eth-p

  1. No difference:

Image

  1. $ ll | bat --color=always --decorations=never --paging=never | grep -o $'\033\\[[^m]*m' | sed $'s/\033/^/g' | sort -u gives:
^[0m
^[38;5;231m

Taylor-C-Reese avatar May 14 '25 17:05 Taylor-C-Reese

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:

eth-p avatar May 14 '25 19:05 eth-p

I see. Is there a simple way to shut that off?

Taylor-C-Reese avatar May 15 '25 05:05 Taylor-C-Reese

Probably to edit the theme and choose a different foreground color: https://github.com/sharkdp/bat?tab=readme-ov-file#highlighting-theme

keith-hall avatar May 17 '25 07:05 keith-hall