From b1dcd5aecd676950bf550581b744c6e1bbe32317 Mon Sep 17 00:00:00 2001 From: Jeremy Schlatter Date: Fri, 16 Jul 2021 12:25:01 -0700 Subject: feat: add support for xonsh (#2807) * feat: add support for xonsh * xonsh: add STARSHIP_SESSION_KEY * xonsh: implement STARSHIP_SESSION_KEY in xonsh * docs: mention tcsh, elvish, and nu in more places * xonsh: change STARSHIP_SESSION_KEY implementation See https://github.com/starship/starship/pull/2807#discussion_r667064149 * xonsh: fix jobs implementation * xonsh: do not silently discard stderr from starship --- src/modules/shell.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'src/modules/shell.rs') diff --git a/src/modules/shell.rs b/src/modules/shell.rs index d8a5f8e0b..0b141ec8a 100644 --- a/src/modules/shell.rs +++ b/src/modules/shell.rs @@ -25,6 +25,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { Shell::Elvish => Some(config.elvish_indicator), Shell::Tcsh => Some(config.tcsh_indicator), Shell::Nu => Some(config.nu_indicator), + Shell::Xonsh => Some(config.xonsh_indicator), Shell::Unknown => Some(config.unknown_indicator), }, _ => None, @@ -37,6 +38,7 @@ pub fn module<'a>(context: &'a Context) -> Option> { "ion_indicator" => Some(Ok(config.ion_indicator)), "elvish_indicator" => Some(Ok(config.elvish_indicator)), "tcsh_indicator" => Some(Ok(config.tcsh_indicator)), + "xonsh_indicator" => Some(Ok(config.xonsh_indicator)), "unknown_indicator" => Some(Ok(config.unknown_indicator)), _ => None, }) @@ -279,6 +281,35 @@ mod tests { assert_eq!(expected, actual); } + #[test] + fn test_xonsh_default_format() { + let expected = Some(format!("{} ", "xsh")); + let actual = ModuleRenderer::new("shell") + .shell(Shell::Xonsh) + .config(toml::toml! { + [shell] + disabled = false + }) + .collect(); + + assert_eq!(expected, actual); + } + + #[test] + fn test_xonsh_custom_format() { + let expected = Some(format!("{} ", Color::Cyan.bold().paint("xonsh"))); + let actual = ModuleRenderer::new("shell") + .shell(Shell::Xonsh) + .config(toml::toml! { + [shell] + xonsh_indicator = "[xonsh](bold cyan)" + disabled = false + }) + .collect(); + + assert_eq!(expected, actual); + } + #[test] fn test_custom_format_conditional_indicator_match() { let expected = Some(format!("{} ", "B")); -- cgit v1.2.3