Skip to content

Commit b6158c0

Browse files
authored
Merge pull request #3168 from bash/fix-env-var-names
Fix name of BAT_THEME_{DARK,LIGHT} env vars
2 parents 1321160 + 8a11a46 commit b6158c0

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
## Features
44

55
## Bugfixes
6+
* Fix `BAT_THEME_DARK` and `BAT_THEME_LIGHT` being ignored, see issue #3171 and PR #3168 (@bash)
67

78
## Other
89

Diff for: src/theme.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pub mod env {
1010
/// See [`crate::theme::ThemeOptions::theme`].
1111
pub const BAT_THEME: &str = "BAT_THEME";
1212
/// See [`crate::theme::ThemeOptions::theme_dark`].
13-
pub const BAT_THEME_DARK: &str = "BAT_THEME";
13+
pub const BAT_THEME_DARK: &str = "BAT_THEME_DARK";
1414
/// See [`crate::theme::ThemeOptions::theme_light`].
15-
pub const BAT_THEME_LIGHT: &str = "BAT_THEME";
15+
pub const BAT_THEME_LIGHT: &str = "BAT_THEME_LIGHT";
1616
}
1717

1818
/// Chooses an appropriate theme or falls back to a default theme

Diff for: tests/integration_tests.rs

+40
Original file line numberDiff line numberDiff line change
@@ -2265,6 +2265,46 @@ fn theme_arg_overrides_env_withconfig() {
22652265
.stderr("");
22662266
}
22672267

2268+
#[test]
2269+
fn theme_light_env_var_is_respected() {
2270+
bat()
2271+
.env("BAT_THEME_LIGHT", "Coldark-Cold")
2272+
.env("COLORTERM", "truecolor")
2273+
.arg("--theme=light")
2274+
.arg("--paging=never")
2275+
.arg("--color=never")
2276+
.arg("--terminal-width=80")
2277+
.arg("--wrap=never")
2278+
.arg("--decorations=always")
2279+
.arg("--style=plain")
2280+
.arg("--highlight-line=1")
2281+
.write_stdin("Lorem Ipsum")
2282+
.assert()
2283+
.success()
2284+
.stdout("\x1B[48;2;208;218;231mLorem Ipsum\x1B[0m")
2285+
.stderr("");
2286+
}
2287+
2288+
#[test]
2289+
fn theme_dark_env_var_is_respected() {
2290+
bat()
2291+
.env("BAT_THEME_DARK", "Coldark-Dark")
2292+
.env("COLORTERM", "truecolor")
2293+
.arg("--theme=dark")
2294+
.arg("--paging=never")
2295+
.arg("--color=never")
2296+
.arg("--terminal-width=80")
2297+
.arg("--wrap=never")
2298+
.arg("--decorations=always")
2299+
.arg("--style=plain")
2300+
.arg("--highlight-line=1")
2301+
.write_stdin("Lorem Ipsum")
2302+
.assert()
2303+
.success()
2304+
.stdout("\x1B[48;2;33;48;67mLorem Ipsum\x1B[0m")
2305+
.stderr("");
2306+
}
2307+
22682308
#[test]
22692309
fn theme_env_overrides_config() {
22702310
bat_with_config()

0 commit comments

Comments
 (0)