Skip to content
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 request: argument for changing specific theme color #339

Open
PoiScript opened this issue Oct 8, 2018 · 15 comments
Open

feature request: argument for changing specific theme color #339

PoiScript opened this issue Oct 8, 2018 · 15 comments
Labels
feature-request New feature or request themes

Comments

@PoiScript
Copy link

Hello, thank you for your awesome works on bat ! But I think there is a feature that still missing.

Suppose that I just want to change the line number color, I have to make a copy of the theme file and change its gutterForeground value. And the theme file is verbose, normally 400+ lines.

So it will be great the bat can provide an argument to overwirte the theme color e.g. bat --theme Tomorrow-Night --colors gutterForeground=f5f5f5 README.md.

@sharkdp
Copy link
Owner

sharkdp commented Oct 8, 2018

Hello, thank you for your awesome works on bat !

Thank you for the feedback!

So it will be great the bat can provide an argument to overwirte the theme color e.g. bat --theme Tomorrow-Night --colors gutterForeground=f5f5f5 README.md.

Sounds like a good idea to me.

I think it will be difficult to support this for every possible color that can be defined in a Sublime Syntax file (these would have to be looked up first), but we could start with the basic colors like gutterForeground, yes. syntect should allow us to easily modify those: https://docs.rs/syntect/2.1.0/syntect/highlighting/struct.ThemeSettings.html

As for the command-line option syntax, I'd suggest --set-theme-color gutterForeground f5f5f5 --set-theme-color foreground f0f0f0. It's not like anyone is going to type these more than once anyway.

@PoiScript
Copy link
Author

PoiScript commented Oct 9, 2018

Thank you for your quick response. I also noticed that you're working on the configuration file now, so I suggest that you can add a command like bat config set gutterForeground f5f5f5 which will modify the configuration file automatically. So people don't have to type these long and long option every time.

@jetzerb
Copy link

jetzerb commented Nov 26, 2018

A related problem: The "reverse" text from the bat theme obscures the highlighting of my search terms within my pager. A demonstration:

$ (BAT_PAGER=/usr/bin/less; bat --list-themes --color always |bat --paging always)

Then, hit G to drop down to the bottom of the output, I've included screenshots from before and after I searched for the word "let". Don't see much difference except in the last two themes (TwoDark and zenburn).

I would like a flag and/or environment variable that would override the settings so that any coloring that the theme applies to the background would instead be applied to the foreground. Then the only reverse text in the output would be my search terms. Something along the lines of:

  • export BAT_THEME_STYLE=foreground
  • bat --theme-style foreground

And the screenshots:
image

@sharkdp
Copy link
Owner

sharkdp commented Nov 26, 2018

@jetzerb bat will never colorize the background. The background-colorized patches should actually be italic, but it seems like your terminal does not support that.

Can you please make sure that:

  • you are running the latest version of bat (0.9.0). We have recently disabled italics by default
  • you are not passing --italic-text=always in the config file.

@jetzerb
Copy link

jetzerb commented Nov 26, 2018

@sharkdp: My apologies. I had been running v0.6.0. I've upgraded to 0.9.0 and now none of the text is showing up with a colored background. I'm not seeing any italics either though. and if I call bat with --italic-text=always, some text shows in reverse, like the screenshots I included in my previous comment.

Oh, looks like this has something to do with tmux...If I detach from tmux, I see italic text instead of reverse text. Google leads me here. I'll have to investigate that...

@sharkdp
Copy link
Owner

sharkdp commented Nov 27, 2018

Oh, looks like this has something to do with tmux...If I detach from tmux, I see italic text instead of reverse text. Google leads me here. I'll have to investigate that...

That's exactly the reason why we have decided to disable italics by default.

@sharkdp sharkdp closed this as completed Nov 27, 2018
@sharkdp sharkdp reopened this Nov 27, 2018
@jetzerb
Copy link

jetzerb commented Nov 27, 2018

For anyone else who might have this problem...
Per the tmux FAQ:


I don't see italics! Or italics and reverse are the wrong way round!

GNU screen does not support italics and the "screen" terminal description uses the italics escape sequence incorrectly.

As of tmux 2.1, if default-terminal is set to "screen" or matches "screen-*", tmux will behave like screen and italics will be disabled.

To enable italics, make sure you are using the tmux terminal description:

set -g default-terminal "tmux"

After setting the default terminal to "tmux", I can see colors, bold, italic, and reverse text. I'm using Oh My Tmux!. I'll see if the author has any thoughts on changing the default terminal from "screen-256color".

@sharkdp
Copy link
Owner

sharkdp commented Nov 28, 2018

@jetzerb Thank you very much for quoting this here. We should add this to the https://github.com/sharkdp/bat#troubleshooting section in the README.

@jaygooby
Copy link

I'm using regular gnu screen and as with tmux, there's some weird issues with underlining.

This is gnu screen (no fixes), gnu screen (underline fixes) and regular terminal (no gnu screen) side by side:

bats-gnu-screen

I fixed my gnu screen underline issues using details from here: https://superuser.com/a/189503/92621 and added

# fix odd underlining and italic issues
attrcolor u "-u R"
attrcolor d -d

to my .screenrc. I'm still not sure how to get the same colours with bat inside gnu screen as you do without it (red versus orange, etc in the screenshot). It is compiled with 256 colour support.

@sharkdp
Copy link
Owner

sharkdp commented Aug 31, 2019

@jaygooby Can you please open a new ticket for this? The whole discussion never really belonged here.

This might be related to COLORTERM=truecolor still being set inside the screen session (because it was set by your terminal emulator?). You could try to unset it inside the screen session.

@salmankhilji
Copy link

I too would like to be able to customize the --highlight-line color using a command line option.

@FallenGameR
Copy link

Same here. I'm using theme "Visual Studio Dark+". And it practically doesn't highlight anything in windows terminal - the contrast is not noticeable.

@aerosol
Copy link

aerosol commented May 30, 2023

Out of the box, using the "Solarized (dark)" theme, the highlight color is quite aggressive and makes the text difficult to read.

It does not matter if I set --italic-text=always.

I'd like to understand where this color is coming from exactly. How can I patch it myself?

I'm pretty sure it's neither of my terminals and tmux also does not affect it. Can I have some pointers please? Thank you!

image

@keith-hall
Copy link
Collaborator

I'd like to understand where this color is coming from exactly.

https://github.com/braver/Solarized/blob/87e01090cf5fb821a234265b3138426ae84900e7/Solarized%20(dark).tmTheme#LL25C14-L25C22

How can I patch it myself?

I guess copy the tmTheme file and follow the custom theme instructions

@aerosol
Copy link

aerosol commented May 30, 2023

Ah, thanks @keith-hall, only now realised the themes are in git submodules 😅

Looks like this value (#1CD1FF12) defines opacity and I doubt terminals can handle that. Thanks again, I can take it from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request themes
Projects
None yet
Development

No branches or pull requests

8 participants