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

[macos] Dark mode #641

Closed
jerguslejko opened this issue Aug 29, 2019 · 6 comments
Closed

[macos] Dark mode #641

jerguslejko opened this issue Aug 29, 2019 · 6 comments
Labels
feature-request New feature or request question Further information is requested themes

Comments

@jerguslejko
Copy link
Contributor

Hi,

is there a way to instruct bat to use a different theme when the OS (macOS in particular) is using a dark theme/mode?

Right now, I use this "hack" which works fine, but I'm wondering if there is a more native approach to this.

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

Thank you!

@eth-p
Copy link
Collaborator

eth-p commented Aug 29, 2019

I also use macOS, and your wrapper approach is currently the only way it's possible right now.

It wouldn't be hard to add native support for macOS dark mode, but I feel like this isn't something that should be included inside bat itself. Any implementation I can think of off the top of my head is either going to be:

A. A hidden version of your hack that forks defaults read.

B. Require a Rust<->ObjC binding or FFI.

In the case of the latter, that's a huge dependency to add for a small feature that doesn't really add anything to improve the core functionality of bat itself.

In either case though, I can see this quickly becoming feature creep when people want to add Windows/[Insert Linux DE] support for dark mode detection. It also doesn't really take the terminal theme into consideration (e.g. I use a dark terminal with light mode), which could be counterintuitive.

But, that being said, I think adding your wrapper script to the documentation would be a great idea to help other people who want theme switching based on macOS dark/light mode.

@sharkdp
Copy link
Owner

sharkdp commented Aug 31, 2019

@jerguslejko Thank you for your feedback!

I'm with @eth-p on this.

But, that being said, I think adding your wrapper script to the documentation would be a great idea to help other people who want theme switching based on macOS dark/light mode.

👍

@sharkdp sharkdp added feature-request New feature or request question Further information is requested themes labels Aug 31, 2019
@jerguslejko
Copy link
Contributor Author

@eth-p @sharkdp makes total sense, thanks! I can submit a PR with the wrapper script. Should that be included in the "Customization" section?

@sharkdp
Copy link
Owner

sharkdp commented Sep 3, 2019

I can submit a PR with the wrapper script

Sounds great. Maybe in a new scripts folder in /assets?

Should that be included in the "Customization" section?

👍

@sharkdp
Copy link
Owner

sharkdp commented Sep 15, 2019

Closed in #662 by @jerguslejko

@aykevl
Copy link

aykevl commented Jul 28, 2023

In either case though, I can see this quickly becoming feature creep when people want to add Windows/[Insert Linux DE] support for dark mode detection. It also doesn't really take the terminal theme into consideration (e.g. I use a dark terminal with light mode), which could be counterintuitive.

Just for anybody coming across this issue: this isn't actually necessary. See #1746 for details.

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 question Further information is requested themes
Projects
None yet
Development

No branches or pull requests

4 participants