-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature: Allow color theme overrides on the command line #1745
Comments
Thanks for the feedback. There's some existing discussion regarding this here:
I would personally ignore the
I would vote for separating the scope from the "color context" being changed, for simplicity and clarity. i.e. |
Thanks for a good feature request. Let's close this as a Duplicate of #339 though and keep discussion in one place. |
Duplicate of #339 |
Thanks!
Thanks again for making such a useful tool, @sharkdp. Please consider adding a "Donate" button / pill to your README.md so I can toss you some beer money.
TL;DR
I want to be able to override the "highlight" color via a flag, but while we're at it, it seems it might be useful for other projects that build on
bat
to be able to change colors of arbitrary things.(I've worked around this locally, for the time being, by creating a copy of the
.tmTheme
I'm interested in, renaming it, making the modifications I want, and re-creating the cache. This is how I ran across #1726.)Feature Request
One of the cooler tools that I've seen built on top of
bat
isgit-delta
, which is also a Rust project, and manually overrides some of the theme color elements in order to show added lines as green, and removed lines as red (depending on options).For example, it would be nice to be able to specify e.g.
As an example for WHY this is needed, Solarized Dark's default highlight color is #073642, but it shows up as #1ED1FF (bright blue) in iTerm2 using the official Solarized Dark theme at the same time.
It would be nice to be able to easily override these settings, without modifying the underlying theme and recompiling all of the assets.
Stretch Goals, Risks and Complications
This might be more complicated than face value, the above setting is actually at the PLIST path
settings[0].settings.lineHighlight
, and the enclosing dictionary for default settings has noname
orscope
entry (i.e., it is describing the default settings, which is why I chose to usedefault.lineHighlight
in my example above).Changing the highlight color of other settings (e.g. the color of a quoted string) may be more difficult, since they have different names and scopes. Consider trying to change the color of strings -- there are multiple settings
String
, scope:string
StringNumber
, scope:string
Regexp
, scope:string.regexp
Quoted String
, scope:string.quoted.double, string.quoted.single
and so on...
Overall, Solarized Dark has 179 different named color settings / scopes / etc.
Providing command-line access to these might look something like this, which only overrides the settings with
scope=="string"
(and notstring.regexp
) and defaults to overriding theforeground
setting.While overriding all scopes that match an (optional) suffix might look like:
Which would match
string
,string.regexp
,string.quoted.double
,string.quoted.single
, and any otherstring.xxx
scope's foreground color.With this in place, it should be possible to override other settings (or create non-existent ones). Consider setting the default background color, and the background color just for strings. It might look like:
Caveats
The mechanism I suggest for wildcards, using an asterisk (
*
) will probably cause most shells to try to use globbing, and thus require single-quoting. This is a footgun. Some shells will leave the star in-place when it fails to glob correctly (e.g.bash
) but others will throw an error (e.g.zsh
).It might be better to use an operator like
%
instead of*
, but I don't want to go back and edit this whole thing again for fear of not being consistent.Closing
Ultimately the parsing and scoping etc. process are probably cumbersome (and I expect this is why you ship pre-compiled
.bin
files).Hopefully, at least for the the top-level, default colors this is achievable.
The text was updated successfully, but these errors were encountered: