Bat: Minor: allow specifying character for "space" in `-A` mode

Created on 11 Jun 2020  Â·  6Comments  Â·  Source: sharkdp/bat

Right now, spaces are visualized as heavy dots:
image
which is fine, but sometimes I'd prefer something a bit less overwhelming, while still being able to count my YAML indent.
It would be a nice addition to allow specifying the unicode char and/or color to use for the space-replacement char.

feature-request good first issue themes

Most helpful comment

Maybe switch to "·" (U+00B7) Middle Dot from "•" (U+2022) Bullet?

I couldn't make the colors work after 10 seconds of fiddling, but here's the difference:

| Before | After |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Screen Shot 2020-07-02 at 12 27 49 AM | Screen Shot 2020-07-02 at 12 26 36 AM |

All 6 comments

I've been poking about in the code, and picking a character is pretty straightforward . The syntax coloring is currently linked to the heavy dot character, which I haven't been able to fix (yet).

The syntax is something like: bat -A --space-char="*" somefile, which isn't terrible.

However, it adds another parameter to preprocessor::replace_nonprintable, so it'll conflict with #1066 (until that's merged) and it feels a little clunky.

This feature adds only a little bloat but sets a precedent for heavy customizations. I think the feature is useful, but I'm not sure if it should be added.

@sharkdp, is this something that should be added?

Thank you for reporting this.

TBH, I'd rather not add a new command-line option for this. There would be so many other things to configure/control on the same level. Maybe we should rather try to improve the default option? I agree that the current display of the space character and the color are maybe a bit too much. How about trying to use a less vibrant color? I'm also fine with a less heavy central-dot character.

Maybe switch to "·" (U+00B7) Middle Dot from "•" (U+2022) Bullet?

I couldn't make the colors work after 10 seconds of fiddling, but here's the difference:

| Before | After |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Screen Shot 2020-07-02 at 12 27 49 AM | Screen Shot 2020-07-02 at 12 26 36 AM |

Maybe switch to "·" (U+00B7) Middle Dot from "•" (U+2022) Bullet?

Sounds good to me

I couldn't make the colors work after 10 seconds of fiddling, but here's the difference:

You need to adapt assets/syntaxes/02_Extra/show-nonprintable.sublime-syntax if you change the character. This file also needs to be modified if we want to change the color. Note that you have to run bash assets/create.sh and rebuild bat after making a change to that file.

Note that you have to run bash assets/create.sh and rebuild bat after making a change to that file.

Aha! That's what I was missing. Is that documented anywhere, or passed on by word of mouth?

Changed in v0.16.0.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

scalp42 picture scalp42  Â·  3Comments

adamtabrams picture adamtabrams  Â·  3Comments

sharkdp picture sharkdp  Â·  3Comments

issmirnov picture issmirnov  Â·  3Comments

yannallain picture yannallain  Â·  3Comments