mirror of
https://github.com/sharkdp/bat.git
synced 2025-01-03 04:08:50 +01:00
docs: Include GNOME bash script for Dark Mode
Title. I developed this on Fedora 39 with GNOME. Tested and works on my setup as expected.
This commit is contained in:
parent
b4e3a84e1a
commit
a5903401af
30
README.md
30
README.md
@ -658,7 +658,7 @@ sidebar. Calling `bat` with `--tabs=0` will override it and let tabs be consumed
|
||||
|
||||
### Dark mode
|
||||
|
||||
If you make use of the dark mode feature in macOS, you might want to configure `bat` to use a different
|
||||
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 _dark mode_
|
||||
and the `GitHub` theme when in the _light mode_.
|
||||
|
||||
@ -666,6 +666,34 @@ and the `GitHub` theme when in the _light mode_.
|
||||
alias cat="bat --theme=\$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo default || echo GitHub)"
|
||||
```
|
||||
|
||||
The same dark mode feature is now available in **GNOME** and affects the `org.gnome.desktop.interface color-scheme` setting. The following code converts the above to use said setting.
|
||||
|
||||
```bash
|
||||
# .bashrc
|
||||
sys_color_scheme_is_dark() {
|
||||
condition=$(gsettings get org.gnome.desktop.interface color-scheme)
|
||||
condition=$(echo "$condition" | tr -d "[:space:]'")
|
||||
if [ $condition == "prefer-dark" ]; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
bat_alias_wrapper() {
|
||||
#get color scheme
|
||||
sys_color_scheme_is_dark
|
||||
if [[ $? -eq 0 ]]; then
|
||||
# bat command with dark color scheme
|
||||
bat --theme=default "$@"
|
||||
else
|
||||
# bat command with light color scheme
|
||||
bat --theme=GitHub "$@"
|
||||
fi
|
||||
}
|
||||
alias cat='bat_alias_wrapper'
|
||||
```
|
||||
|
||||
|
||||
## Configuration file
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user