From 9b52475e541f751e8c650587cd8c1615fe00b1d0 Mon Sep 17 00:00:00 2001 From: Tyler Ruckinger Date: Thu, 2 Jun 2022 17:46:46 -0400 Subject: [PATCH 1/3] fix(nu): don't use `cygpath` for starship binary path in init (#4001) nu on windows need not be posix --- src/init/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/init/mod.rs b/src/init/mod.rs index be00940ae..9e30d0c44 100644 --- a/src/init/mod.rs +++ b/src/init/mod.rs @@ -171,7 +171,7 @@ pub fn init_stub(shell_name: &str) -> io::Result<()> { r#"eval `({} init tcsh --print-full-init)`"#, starship.sprint_posix()? ), - "nu" => print_script(NU_INIT, &StarshipPath::init()?.sprint_posix()?), + "nu" => print_script(NU_INIT, &StarshipPath::init()?.sprint()?), "xonsh" => print!( r#"execx($({} init xonsh --print-full-init))"#, starship.sprint_posix()? From 1e2bc8477ebde8c77ddd066421978eee030454c9 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 3 Jun 2022 04:07:31 -0400 Subject: [PATCH 2/3] build: bump open from 2.1.2 to 2.1.3 (#4038) Bumps [open](https://github.com/Byron/open-rs) from 2.1.2 to 2.1.3. - [Release notes](https://github.com/Byron/open-rs/releases) - [Changelog](https://github.com/Byron/open-rs/blob/main/changelog.md) - [Commits](https://github.com/Byron/open-rs/compare/v2.1.2...v2.1.3) --- updated-dependencies: - dependency-name: open dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Cargo.lock | 51 +++++++++++++++++++++++++++++++++++++++++++++++---- Cargo.toml | 2 +- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 57289663a..d4c7b85fd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1260,12 +1260,12 @@ checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" [[package]] name = "open" -version = "2.1.2" +version = "2.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0524af9508f9b5c4eb41dce095860456727748f63b478d625f119a70e0d764a" +checksum = "f2423ffbf445b82e58c3b1543655968923dd06f85432f10be2bb4f1b7122f98c" dependencies = [ "pathdiff", - "winapi", + "windows-sys 0.36.1", ] [[package]] @@ -1572,7 +1572,7 @@ checksum = "2474cb354f8a653da59aa61266a4491febd45376217c36dd158ebcc91f25dffb" dependencies = [ "crossbeam-channel", "libc", - "windows-sys", + "windows-sys 0.35.0", ] [[package]] @@ -2588,12 +2588,31 @@ dependencies = [ "windows_x86_64_msvc 0.35.0", ] +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc 0.36.1", + "windows_i686_gnu 0.36.1", + "windows_i686_msvc 0.36.1", + "windows_x86_64_gnu 0.36.1", + "windows_x86_64_msvc 0.36.1", +] + [[package]] name = "windows_aarch64_msvc" version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db3bc5134e8ce0da5d64dcec3529793f1d33aee5a51fc2b4662e0f881dd463e6" +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + [[package]] name = "windows_aarch64_msvc" version = "0.37.0" @@ -2612,6 +2631,12 @@ version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0343a6f35bf43a07b009b8591b78b10ea03de86b06f48e28c96206cd0f453b50" +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + [[package]] name = "windows_i686_gnu" version = "0.37.0" @@ -2630,6 +2655,12 @@ version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1acdcbf4ca63d8e7a501be86fee744347186275ec2754d129ddeab7a1e3a02e4" +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + [[package]] name = "windows_i686_msvc" version = "0.37.0" @@ -2648,6 +2679,12 @@ version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "893c0924c5a990ec73cd2264d1c0cba1773a929e1a3f5dbccffd769f8c4edebb" +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + [[package]] name = "windows_x86_64_gnu" version = "0.37.0" @@ -2666,6 +2703,12 @@ version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a29bd61f32889c822c99a8fdf2e93378bd2fae4d7efd2693fab09fcaaf7eff4b" +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + [[package]] name = "windows_x86_64_msvc" version = "0.37.0" diff --git a/Cargo.toml b/Cargo.toml index 996496b1b..3a3e2b038 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -50,7 +50,7 @@ log = { version = "0.4.16", features = ["std"] } # see: https://github.com/NixOS/nixpkgs/issues/160876 notify-rust = { version = "4.5.8", optional = true } once_cell = "1.12.0" -open = "2.1.2" +open = "2.1.3" os_info = "3.4.0" path-slash = "0.1.4" pest = "2.1.3" From 146976351ec804ab1594d5262a1e0dd2d2de4972 Mon Sep 17 00:00:00 2001 From: Mat Jones Date: Sat, 4 Jun 2022 10:41:24 +0000 Subject: [PATCH 3/3] fix(fish): add proper vi mode detection for fish shell (#3839) * add proper vi mode detection for fish shell * update tests * fix test * update config-schema.json * update docs * add warning about symbols only supported in fish --- .github/config-schema.json | 17 ++++++++++++++++- docs/config/README.md | 19 ++++++++++++------- src/configs/character.rs | 6 ++++++ src/modules/character.rs | 37 +++++++++++++++++++++++++++++++++++-- 4 files changed, 69 insertions(+), 10 deletions(-) diff --git a/.github/config-schema.json b/.github/config-schema.json index 3ed03d145..16de446c4 100644 --- a/.github/config-schema.json +++ b/.github/config-schema.json @@ -122,7 +122,10 @@ "error_symbol": "[❯](bold red)", "format": "$symbol ", "success_symbol": "[❯](bold green)", - "vicmd_symbol": "[❮](bold green)" + "vicmd_symbol": "[❮](bold green)", + "vimcmd_replace_one_symbol": "[❮](bold purple)", + "vimcmd_replace_symbol": "[❮](bold purple)", + "vimcmd_visual_symbol": "[❮](bold yellow)" }, "allOf": [ { @@ -1784,6 +1787,18 @@ "default": "[❮](bold green)", "type": "string" }, + "vimcmd_visual_symbol": { + "default": "[❮](bold yellow)", + "type": "string" + }, + "vimcmd_replace_symbol": { + "default": "[❮](bold purple)", + "type": "string" + }, + "vimcmd_replace_one_symbol": { + "default": "[❮](bold purple)", + "type": "string" + }, "disabled": { "default": false, "type": "boolean" diff --git a/docs/config/README.md b/docs/config/README.md index 61649ca53..db9c51792 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -572,18 +572,23 @@ look at [this example](#with-custom-error-shape). ::: warning `vicmd_symbol` is only supported in cmd, fish and zsh. +`vimcmd_replace_one_symbol`, `vimcmd_replace_symbol`, and `vimcmd_visual_symbol` +are only supported in fish due to [upstream issues with mode detection in zsh](https://github.com/starship/starship/issues/625#issuecomment-732454148). ::: ### Options -| Option | Default | Description | -| ---------------- | ------------------- | -------------------------------------------------------------------------------- | -| `format` | `"$symbol "` | The format string used before the text input. | -| `success_symbol` | `"[❯](bold green)"` | The format string used before the text input if the previous command succeeded. | -| `error_symbol` | `"[❯](bold red)"` | The format string used before the text input if the previous command failed. | -| `vicmd_symbol` | `"[❮](bold green)"` | The format string used before the text input if the shell is in vim normal mode. | -| `disabled` | `false` | Disables the `character` module. | +| Option | Default | Description | +| -------------------------- | -------------------- | --------------------------------------------------------------------------------------- | +| `format` | `"$symbol "` | The format string used before the text input. | +| `success_symbol` | `"[❯](bold green)"` | The format string used before the text input if the previous command succeeded. | +| `error_symbol` | `"[❯](bold red)"` | The format string used before the text input if the previous command failed. | +| `vicmd_symbol` | `"[❮](bold green)"` | The format string used before the text input if the shell is in vim normal mode. | +| `vicmd_replace_one_symbol` | `"[❮](bold purple)"` | The format string used before the text input if the shell is in vim `replace_one` mode. | +| `vimcmd_replace_symbol` | `"[❮](bold purple)"` | The format string used before the text input if the shell is in vim replace mode. | +| `vimcmd_visual_symbol` | `"[❮](bold yellow)"` | The format string used before the text input if the shell is in vim replace mode. | +| `disabled` | `false` | Disables the `character` module. | ### Variables diff --git a/src/configs/character.rs b/src/configs/character.rs index 91cef60c4..eb28f9cd1 100644 --- a/src/configs/character.rs +++ b/src/configs/character.rs @@ -8,6 +8,9 @@ pub struct CharacterConfig<'a> { pub success_symbol: &'a str, pub error_symbol: &'a str, pub vicmd_symbol: &'a str, + pub vimcmd_visual_symbol: &'a str, + pub vimcmd_replace_symbol: &'a str, + pub vimcmd_replace_one_symbol: &'a str, pub disabled: bool, } @@ -18,6 +21,9 @@ impl<'a> Default for CharacterConfig<'a> { success_symbol: "[❯](bold green)", error_symbol: "[❯](bold red)", vicmd_symbol: "[❮](bold green)", + vimcmd_visual_symbol: "[❮](bold yellow)", + vimcmd_replace_symbol: "[❮](bold purple)", + vimcmd_replace_one_symbol: "[❮](bold purple)", disabled: false, } } diff --git a/src/modules/character.rs b/src/modules/character.rs index e7b65e2ee..39c78b159 100644 --- a/src/modules/character.rs +++ b/src/modules/character.rs @@ -4,7 +4,7 @@ use crate::formatter::StringFormatter; /// Creates a module for the prompt character /// -/// The character segment prints an arrow character in a color dependant on the +/// The character segment prints an arrow character in a color dependent on the /// exit-code of the last executed command: /// - If the exit-code was "0", it will be formatted with `success_symbol` /// (green arrow by default) @@ -13,6 +13,9 @@ use crate::formatter::StringFormatter; pub fn module<'a>(context: &'a Context) -> Option> { enum ShellEditMode { Normal, + Visual, + Replace, + ReplaceOne, Insert, } const ASSUMED_MODE: ShellEditMode = ShellEditMode::Insert; @@ -35,11 +38,17 @@ pub fn module<'a>(context: &'a Context) -> Option> { (Shell::Fish, "default") | (Shell::Zsh, "vicmd") | (Shell::Cmd, "vi") => { ShellEditMode::Normal } + (Shell::Fish, "visual") => ShellEditMode::Visual, + (Shell::Fish, "replace") => ShellEditMode::Replace, + (Shell::Fish, "replace_one") => ShellEditMode::ReplaceOne, _ => ASSUMED_MODE, }; let symbol = match mode { ShellEditMode::Normal => config.vicmd_symbol, + ShellEditMode::Visual => config.vimcmd_visual_symbol, + ShellEditMode::Replace => config.vimcmd_replace_symbol, + ShellEditMode::ReplaceOne => config.vimcmd_replace_one_symbol, ShellEditMode::Insert => { if exit_success { config.success_symbol @@ -168,6 +177,9 @@ mod test { fn fish_keymap() { let expected_vicmd = Some(format!("{} ", Color::Green.bold().paint("❮"))); let expected_specified = Some(format!("{} ", Color::Green.bold().paint("V"))); + let expected_visual = Some(format!("{} ", Color::Yellow.bold().paint("❮"))); + let expected_replace = Some(format!("{} ", Color::Purple.bold().paint("❮"))); + let expected_replace_one = expected_replace.clone(); let expected_other = Some(format!("{} ", Color::Green.bold().paint("❯"))); // fish keymap is default @@ -188,11 +200,32 @@ mod test { .collect(); assert_eq!(expected_specified, actual); - // fish keymap is other + // fish keymap is visual let actual = ModuleRenderer::new("character") .shell(Shell::Fish) .keymap("visual") .collect(); + assert_eq!(expected_visual, actual); + + // fish keymap is replace + let actual = ModuleRenderer::new("character") + .shell(Shell::Fish) + .keymap("replace") + .collect(); + assert_eq!(expected_replace, actual); + + // fish keymap is replace_one + let actual = ModuleRenderer::new("character") + .shell(Shell::Fish) + .keymap("replace_one") + .collect(); + assert_eq!(expected_replace_one, actual); + + // fish keymap is other + let actual = ModuleRenderer::new("character") + .shell(Shell::Fish) + .keymap("other") + .collect(); assert_eq!(expected_other, actual); }