diff --git a/src/modules/shell.rs b/src/modules/shell.rs index fc51b52f..c8b6a2c9 100644 --- a/src/modules/shell.rs +++ b/src/modules/shell.rs @@ -28,6 +28,16 @@ pub fn module<'a>(context: &'a Context) -> Option> { }, _ => None, }) + .map(|var| match var { + "bash_indicator" => Some(Ok(config.bash_indicator)), + "fish_indicator" => Some(Ok(config.fish_indicator)), + "zsh_indicator" => Some(Ok(config.zsh_indicator)), + "powershell_indicator" => Some(Ok(config.powershell_indicator)), + "ion_indicator" => Some(Ok(config.ion_indicator)), + "elvish_indicator" => Some(Ok(config.elvish_indicator)), + "tcsh_indicator" => Some(Ok(config.tcsh_indicator)), + _ => None, + }) .parse(None) }); @@ -237,4 +247,36 @@ mod tests { assert_eq!(expected, actual); } + + #[test] + fn test_custom_format_conditional_indicator_match() { + let expected = Some(format!("{} ", "B")); + let actual = ModuleRenderer::new("shell") + .shell(Shell::Bash) + .config(toml::toml! { + [shell] + bash_indicator = "B" + format = "($bash_indicator )" + disabled = false + }) + .collect(); + + assert_eq!(expected, actual); + } + + #[test] + fn test_custom_format_conditional_indicator_no_match() { + let expected = None; + let actual = ModuleRenderer::new("shell") + .shell(Shell::Fish) + .config(toml::toml! { + [shell] + bash_indicator = "B" + format = "($indicator )" + disabled = false + }) + .collect(); + + assert_eq!(expected, actual); + } }