diff --git a/CHANGELOG.md b/CHANGELOG.md index 1400f0556..82a44f1c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,7 +24,7 @@ Added a `--color` option which allows explicitly enabling/disabling colour output. Added a `--background` option which controls whether difftastic uses -bright or dark colours. +bright or dark colours. This can also be controlled by `DFT_BACKGROUND`. ## 0.17 (released 25 January 2022) diff --git a/src/main.rs b/src/main.rs index 08eaa9f3d..e929cd1c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -149,9 +149,8 @@ fn app() -> clap::App<'static> { ) .arg( Arg::new("background").long("background") - .default_value("dark") .possible_values(["dark", "light"]) - .help("Set the background color. Difftastic will prefer brighter colours on dark backgrounds.") + .help("Set the background color. Overrides $DFT_BACKGROUND if present. Difftastic will prefer brighter colours on dark backgrounds.") ) .arg( Arg::new("paths") @@ -245,7 +244,15 @@ fn parse_args() -> Mode { BackgroundColor::Dark } } else { - BackgroundColor::Dark + if let Ok(background) = env::var("DFT_BACKGROUND") { + if background == "light" { + BackgroundColor::Light + } else { + BackgroundColor::Dark + } + } else { + BackgroundColor::Dark + } }; Mode::Diff {