fix: Consider `$STARSHIP_CONFIG` in `configure` (#795)

Makes starship configure consider the $STARSHIP_CONFIG variable before falling back to the default of ~/.config/starship.toml.
This commit is contained in:
AppleTheGolden 2019-12-31 00:46:02 +01:00 committed by Kevin Song
parent a8e20ef387
commit 6bafe4cd66
1 changed files with 10 additions and 5 deletions

View File

@ -40,11 +40,16 @@ fn get_editor_internal(visual: Option<OsString>, editor: Option<OsString>) -> Os
} }
fn get_config_path() -> OsString { fn get_config_path() -> OsString {
dirs::home_dir() let config_path = env::var_os("STARSHIP_CONFIG").unwrap_or_else(|| "".into());
.expect("Couldn't find home directory") if config_path.is_empty() {
.join(".config/starship.toml") dirs::home_dir()
.as_os_str() .expect("couldn't find home directory")
.to_owned() .join(".config/starship.toml")
.as_os_str()
.to_owned()
} else {
config_path
}
} }
#[cfg(test)] #[cfg(test)]