mirror of
https://github.com/starship/starship.git
synced 2025-02-07 22:10:48 +01:00
Merge branch 'master' into conditional-style
This commit is contained in:
commit
5fe5e3f565
17
.github/config-schema.json
vendored
17
.github/config-schema.json
vendored
@ -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": [
|
||||
{
|
||||
@ -1791,6 +1794,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"
|
||||
|
51
Cargo.lock
generated
51
Cargo.lock
generated
@ -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"
|
||||
|
@ -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"
|
||||
|
@ -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
|
||||
|
||||
|
@ -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,
|
||||
}
|
||||
}
|
||||
|
@ -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()?
|
||||
|
@ -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<Module<'a>> {
|
||||
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<Module<'a>> {
|
||||
(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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user