Open igorkulman opened 2 years ago
Thank you for reporting. I hope we can agree on that the most important thing is for bat to look good on a default Mac installation, i.e. with Terminal.app.
Then, the question is, how do we deal with custom applications such as iTerm2. First of all, it seems as if iTerm2 3.5 will support Dark Mode, which should elegantly solve the problem you are having.
Until then, I do not think it is unreasonable to require locking the theme so that it works with your non-default terminal emulator. You can do it like this:
bat --generate-config-file
echo '--theme "Monokai Extended"' >> ~/.config/bat/config
That will also make bat startup slightly faster, because it will not check if Dark Mode is enabled or disabled.
You are right the main goal is to make it look well. Is there maybe a theme that looks OK in both a dark and a light terminal?
Thanks for the tip about explicitly setting the theme via a config.
But I wonder how many people that use tools like bat actually use the default terminal instead of iTerm2, kitty, alacritty etc.
But I wonder how many people that use tools like bat actually use the default terminal instead of iTerm2, kitty, alacritty etc.
Good point. Let's maybe leave this open for a while to see if others have a similar feedback.
There could be a config setting where you explicitly set the theme for light and dark variants.
To workaround this I have this in my .zshrc and it works just fine:
function bat() {
THEME=$(defaults read -globalDomain AppleInterfaceStyle &> /dev/null && echo dark || echo light)
if [[ ${THEME} = "dark" ]]; then
export BAT_CONFIG_PATH="${HOME}/.config/bat/config-dark.conf"
else
export BAT_CONFIG_PATH="${HOME}/.config/bat/config-light.conf"
fi
command bat $@
}
I was also bitten by this issue (using iTerm2) and found it to be very unexpected, but I also don't think it's bat's fault either; it's just a bizarre design decision by Apple to change the terminal background based on Dark and Light mode. I just opened Terminal for the first time in a while, and found my font was totally unreadable--not just in bat--because at some point I had adjusted the background color a little, and now dark/light mode leaves this tweaked background color alone while flipping the text color.
So, I've set --theme
now in .config/bat/config. No problem at all, but it was a sudden change and I had to search through the GitHub issues database to figure out what was going on.
One thing I would note is, your README is no longer really accurate on macOS. It says "bat looks good on a dark background by default. However, if your terminal uses a light background, some themes like GitHub or OneHalfLight will work better for you." bat
definitely doesn't look good on a dark background by default, unless that dark background is the result of using dark mode and the standard Terminal.app with an unmodified Basic profile. In fact, if you change Terminal.app's default profile to "Pro" or "Homebrew" (dark bg) instead of Basic, the bat theme is now way too dark. As mentioned by @igorkulman, the kind of user that installs homebrew and uses bat on macOS might also use a non-standard terminal, or at least change the Terminal.app profile to always use a dark terminal even in light mode.
So, I would consider adding a note in the "Highlighting theme" section that on macOS, if you are using a dark terminal background in light mode, you should pin the theme to one appropriate for a dark background such as Monokai Extended
.
What steps will reproduce the bug?
What happens?
Bat v0.22.0 detects macOS in light theme so it used light theme by default making it unreadable in dark terminals like iTerm2.
What did you expect to happen instead?
Switching theme depending on macOS light / dark mode should not be the default behavior.
How did you install
bat
?brew
v0.22.0 on macOS 12.5.1