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: command line option for dark / light theme or theme selection #689

Closed
draptik opened this issue Oct 12, 2019 · 8 comments
Closed

Comments

@draptik
Copy link

draptik commented Oct 12, 2019

Sorry if I missed something in the documentation: Thankful for pointers!

During presentations I often switch between dark and light themes in the terminal (gnome-terminal, urxvt, kitty).

The default theme is optimized for dark background colors.

Can we have a command line option to use a theme optimized for light colored background?

@clarfonthey
Copy link
Contributor

One thing that might be good is to be able to set the preferred dark and light themes separately, and to simply switch between them using a flag or some environment variable.

@sharkdp
Copy link
Owner

sharkdp commented Oct 13, 2019

Sorry if I missed something in the documentation: Thankful for pointers!

We have decided not to include support for this in bat directly (see #641). But there is this: https://github.com/sharkdp/bat#dark-mode

It only works on macOS, so far, but maybe it could be extended to support other terminal emulators as well.

One thing that might be good is to be able to set the preferred dark and light themes separately, and to simply switch between them using a flag or some environment variable.

That is not possible. Once you see the output in the pager, bat has already finished. The program that you are seeing is less.

@clarfonthey
Copy link
Contributor

@sharkdp I meant before bat is run, e.g. a command line flag or environment variable before bat is run. :p

@sharkdp
Copy link
Owner

sharkdp commented Oct 13, 2019

@sharkdp I meant before bat is run

For some reason I thought you wanted to switch dark/light with a key 😄. Must have misread your comment.

e.g. a command line flag or environment variable before bat is run

That's pretty much what is suggested in https://github.com/sharkdp/bat#dark-mode, right?

@draptik
Copy link
Author

draptik commented Oct 14, 2019

Thanks for the feedback!
I completely missed the bat --theme=GitHub.. option.
Sorry for the noise!

@draptik draptik closed this as completed Oct 14, 2019
@bric3
Copy link
Contributor

bric3 commented Apr 21, 2020

I think the prhasing is incorrect

If you make use of the dark mode feature in macOS, you might want to configure bat to use a different theme based on the OS theme. The following snippet uses the default theme when in the light mode and the GitHub theme when in the dark mode.

Because defaults read -g AppleInterfaceStyle will only return Dark if the dark mode is active, otherwise there is an error message. So the following command

bat --theme="$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)"

will instead make bat use

  • default in dark mode
  • Github in light mode

@eth-p
Copy link
Collaborator

eth-p commented Apr 21, 2020

I think the prhasing is incorrect

If you make use of the dark mode feature in macOS, you might want to configure bat to use a different theme based on the OS theme. The following snippet uses the default theme when in the light mode and the GitHub theme when in the dark mode.

Because defaults read -g AppleInterfaceStyle will only return Dark if the dark mode is active, otherwise there is an error message. So the following command

bat --theme="$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)"

will instead make bat use

  • default in dark mode
  • Github in light mode

Good catch. Do you want to make a PR to fix that and I'll merge it, or would you prefer one of us do it?

@bric3
Copy link
Contributor

bric3 commented Apr 21, 2020

@eth-p Done in #933

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants