1
0
mirror of https://github.com/Llewellynvdm/starship.git synced 2024-11-24 21:57:41 +00:00

fix: move get_shell method into Context

This commit is contained in:
Matan Kushner 2020-02-03 17:01:50 -05:00
parent cb6819c7d8
commit 0d1578bbe1
No known key found for this signature in database
GPG Key ID: 4B98C3A8949CA8A4

View File

@ -150,6 +150,18 @@ impl<'a> Context<'a> {
DirContents::from_path_with_timeout(&self.current_dir, timeout)
})
}
fn get_shell() -> Shell {
let shell = std::env::var("STARSHIP_SHELL").unwrap_or_default();
match shell.as_str() {
"bash" => Shell::Bash,
"fish" => Shell::Fish,
"ion" => Shell::Ion,
"powershell" => Shell::PowerShell,
"zsh" => Shell::Zsh,
_ => Shell::Unknown,
}
}
}
#[derive(Debug)]
@ -240,18 +252,6 @@ impl DirContents {
pub fn has_any_extension(&self, exts: &[&str]) -> bool {
exts.iter().any(|ext| self.has_extension(ext))
}
fn get_shell() -> Shell {
let shell = std::env::var("STARSHIP_SHELL").unwrap_or_default();
match shell.as_str() {
"bash" => Shell::Bash,
"fish" => Shell::Fish,
"ion" => Shell::Ion,
"powershell" => Shell::PowerShell,
"zsh" => Shell::Zsh,
_ => Shell::Unknown,
}
}
}
pub struct Repo {