diff options
author | Jeremy Schlatter <jeremy@jeremyschlatter.com> | 2021-07-16 12:25:01 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-07-16 15:25:01 -0400 |
commit | b1dcd5aecd676950bf550581b744c6e1bbe32317 (patch) | |
tree | 43868c15a9eaf0df0fe749e24cfc60e8bbc37901 /src/modules/shell.rs | |
parent | 1eaf996a3645704910ea30b0ee19a97ab4f1daf6 (diff) |
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
Diffstat (limited to 'src/modules/shell.rs')
-rw-r--r-- | src/modules/shell.rs | 31 |
1 files changed, 31 insertions, 0 deletions
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<Module<'a>> { 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<Module<'a>> { "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, }) @@ -280,6 +282,35 @@ mod tests { } #[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")); let actual = ModuleRenderer::new("shell") |