diff --git a/.github/config-schema.json b/.github/config-schema.json index 04f293d52..e572f5502 100644 --- a/.github/config-schema.json +++ b/.github/config-schema.json @@ -1200,6 +1200,7 @@ "Alpaquita": "๐Ÿ”” ", "AlmaLinux": "๐Ÿ’  ", "Alpine": "๐Ÿ”๏ธ ", + "ALTLinux": "โ’ถ ", "Amazon": "๐Ÿ™‚ ", "Android": "๐Ÿค– ", "AOSC": "๐Ÿฑ ", @@ -1209,6 +1210,7 @@ "CachyOS": "๐ŸŽ—๏ธ ", "CentOS": "๐Ÿ’  ", "Debian": "๐ŸŒ€ ", + "Elementary": "๐Ÿ ", "DragonFly": "๐Ÿ‰ ", "Emscripten": "๐Ÿ”— ", "EndeavourOS": "๐Ÿš€ ", @@ -1218,6 +1220,8 @@ "Gentoo": "๐Ÿ—œ๏ธ ", "HardenedBSD": "๐Ÿ›ก๏ธ ", "Illumos": "๐Ÿฆ ", + "Ios": "๐Ÿ“ฑ ", + "InstantOS": "โฒ๏ธ ", "Kali": "๐Ÿ‰ ", "Linux": "๐Ÿง ", "Mabox": "๐Ÿ“ฆ ", @@ -1234,6 +1238,7 @@ "openEuler": "๐Ÿฆ‰ ", "openSUSE": "๐ŸฆŽ ", "OracleLinux": "๐Ÿฆด ", + "PikaOS": "๐Ÿค ", "Pop": "๐Ÿญ ", "Raspbian": "๐Ÿ“ ", "Redhat": "๐ŸŽฉ ", @@ -1247,7 +1252,8 @@ "Unknown": "โ“ ", "Uos": "๐Ÿฒ ", "Void": "๎Š™ ", - "Windows": "๐ŸชŸ " + "Windows": "๐ŸชŸ ", + "Zorin": "๐Ÿ”น " }, "disabled": true } @@ -5035,6 +5041,7 @@ "Alpaquita": "๐Ÿ”” ", "AlmaLinux": "๐Ÿ’  ", "Alpine": "๐Ÿ”๏ธ ", + "ALTLinux": "โ’ถ ", "Amazon": "๐Ÿ™‚ ", "Android": "๐Ÿค– ", "AOSC": "๐Ÿฑ ", @@ -5044,6 +5051,7 @@ "CachyOS": "๐ŸŽ—๏ธ ", "CentOS": "๐Ÿ’  ", "Debian": "๐ŸŒ€ ", + "Elementary": "๐Ÿ ", "DragonFly": "๐Ÿ‰ ", "Emscripten": "๐Ÿ”— ", "EndeavourOS": "๐Ÿš€ ", @@ -5053,6 +5061,8 @@ "Gentoo": "๐Ÿ—œ๏ธ ", "HardenedBSD": "๐Ÿ›ก๏ธ ", "Illumos": "๐Ÿฆ ", + "Ios": "๐Ÿ“ฑ ", + "InstantOS": "โฒ๏ธ ", "Kali": "๐Ÿ‰ ", "Linux": "๐Ÿง ", "Mabox": "๐Ÿ“ฆ ", @@ -5069,6 +5079,7 @@ "openEuler": "๐Ÿฆ‰ ", "openSUSE": "๐ŸฆŽ ", "OracleLinux": "๐Ÿฆด ", + "PikaOS": "๐Ÿค ", "Pop": "๐Ÿญ ", "Raspbian": "๐Ÿ“ ", "Redhat": "๐ŸŽฉ ", @@ -5082,7 +5093,8 @@ "Unknown": "โ“ ", "Uos": "๐Ÿฒ ", "Void": "๎Š™ ", - "Windows": "๐ŸชŸ " + "Windows": "๐ŸชŸ ", + "Zorin": "๐Ÿ”น " } }, "disabled": { diff --git a/Cargo.lock b/Cargo.lock index 435622871..57673082c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2423,6 +2423,7 @@ dependencies = [ "objc2", "objc2-foundation", "objc2-ui-kit", + "schemars", "serde", "windows-sys 0.61.2", ] diff --git a/Cargo.toml b/Cargo.toml index 10717e4bd..16749450e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ license = "ISC" readme = "README.md" repository = "https://github.com/starship/starship" # Note: MSRV is only intended as a hint, and only the latest version is officially supported in starship. -rust-version = "1.85" +rust-version = "1.90" description = """ The minimal, blazing-fast, and infinitely customizable prompt for any shell! โ˜„๐ŸŒŒ๏ธ """ @@ -52,7 +52,7 @@ notify-rust = { version = "4.11.7", optional = true } nu-ansi-term = "0.50.3" open = "5.3.3" # update os module config and tests when upgrading os_info -os_info = "3.14.0" +os_info = { version = "3.14.0", features = ["schemars"] } # for efficient shared state between `git_status` and `git_metrics`, allowing parallel printing. This is for poison-free locks. parking_lot = "0.12.5" path-slash = "0.2.1" diff --git a/docs/config/README.md b/docs/config/README.md index f1db9031a..530440bd1 100644 --- a/docs/config/README.md +++ b/docs/config/README.md @@ -3522,6 +3522,7 @@ AIX = "โžฟ " Alpaquita = "๐Ÿ”” " AlmaLinux = "๐Ÿ’  " Alpine = "๐Ÿ”๏ธ " +ALTLinux = "โ’ถ " Amazon = "๐Ÿ™‚ " Android = "๐Ÿค– " AOSC = "๐Ÿฑ " @@ -3532,6 +3533,7 @@ CachyOS = "๐ŸŽ—๏ธ " CentOS = "๐Ÿ’  " Debian = "๐ŸŒ€ " DragonFly = "๐Ÿ‰ " +Elementary = "๐Ÿ " Emscripten = "๐Ÿ”— " EndeavourOS = "๐Ÿš€ " Fedora = "๐ŸŽฉ " @@ -3540,6 +3542,8 @@ Garuda = "๐Ÿฆ… " Gentoo = "๐Ÿ—œ๏ธ " HardenedBSD = "๐Ÿ›ก๏ธ " Illumos = "๐Ÿฆ " +Ios = "๐Ÿ“ฑ " +InstantOS = "โฒ๏ธ " Kali = "๐Ÿ‰ " Linux = "๐Ÿง " Mabox = "๐Ÿ“ฆ " @@ -3556,6 +3560,7 @@ OpenCloudOS = "โ˜๏ธ " openEuler = "๐Ÿฆ‰ " openSUSE = "๐ŸฆŽ " OracleLinux = "๐Ÿฆด " +PikaOS = "๐Ÿค " Pop = "๐Ÿญ " Raspbian = "๐Ÿ“ " Redhat = "๐ŸŽฉ " @@ -3570,6 +3575,7 @@ Unknown = "โ“ " Uos = "๐Ÿฒ " Void = "๎Š™ " Windows = "๐ŸชŸ " +Zorin = "๐Ÿ”น " ``` ### Variables diff --git a/docs/public/presets/toml/nerd-font-symbols.toml b/docs/public/presets/toml/nerd-font-symbols.toml index 7f4bf13c4..cb15b206b 100644 --- a/docs/public/presets/toml/nerd-font-symbols.toml +++ b/docs/public/presets/toml/nerd-font-symbols.toml @@ -124,6 +124,7 @@ CachyOS = "๏Œƒ " CentOS = "๏Œ„ " Debian = "๏Œ† " DragonFly = "๎ŠŽ " +Elementary = "๏Œ‰ " Emscripten = "๏ˆ… " EndeavourOS = "๏†— " Fedora = "๏ŒŠ " @@ -132,6 +133,7 @@ Garuda = "๓ฐ›“ " Gentoo = "๏Œ " HardenedBSD = "๓ฐžŒ " Illumos = "๓ฐˆธ " +Ios = "๓ฐ€ท " Kali = "๏Œง " Linux = "๏Œš " Mabox = "๎ฌฉ " @@ -158,6 +160,7 @@ Ubuntu = "๏Œ› " Unknown = "๏ˆญ " Void = "๏Œฎ " Windows = "๓ฐฒ " +Zorin = "๏Œฏ " [package] symbol = "๓ฐ— " diff --git a/docs/public/presets/toml/plain-text-symbols.toml b/docs/public/presets/toml/plain-text-symbols.toml index 5a707a12d..4a1f887a0 100644 --- a/docs/public/presets/toml/plain-text-symbols.toml +++ b/docs/public/presets/toml/plain-text-symbols.toml @@ -193,6 +193,7 @@ AIX = "aix " Alpaquita = "alq " AlmaLinux = "alma " Alpine = "alp " +ALTLinux = "alt " Amazon = "amz " Android = "andr " AOSC = "aosc " @@ -203,6 +204,7 @@ CachyOS = "cach " CentOS = "cent " Debian = "deb " DragonFly = "dfbsd " +Elementary = "elem " Emscripten = "emsc " EndeavourOS = "ndev " Fedora = "fed " @@ -211,6 +213,8 @@ Garuda = "garu " Gentoo = "gent " HardenedBSD = "hbsd " Illumos = "lum " +Ios = "ios " +InstantOS = "inst " Kali = "kali " Linux = "lnx " Mabox = "mbox " @@ -227,6 +231,7 @@ OpenCloudOS = "ocos " openEuler = "oeul " openSUSE = "osuse " OracleLinux = "orac " +PikaOS = "pika " Pop = "pop " Raspbian = "rasp " Redhat = "rhl " @@ -241,6 +246,7 @@ Unknown = "unk " Uos = "uos " Void = "void " Windows = "win " +Zorin = "zorn " [package] symbol = "pkg " diff --git a/src/configs/os.rs b/src/configs/os.rs index e13696486..04ace682b 100644 --- a/src/configs/os.rs +++ b/src/configs/os.rs @@ -12,7 +12,6 @@ use serde::{Deserialize, Serialize}; pub struct OSConfig<'a> { pub format: &'a str, pub style: &'a str, - #[cfg_attr(feature = "config-schema", schemars(with = "IndexMap"))] pub symbols: IndexMap, pub disabled: bool, } @@ -33,6 +32,7 @@ impl Default for OSConfig<'_> { Type::Alpaquita => "๐Ÿ”” ", Type::AlmaLinux => "๐Ÿ’  ", Type::Alpine => "๐Ÿ”๏ธ ", + Type::ALTLinux => "โ’ถ ", Type::Amazon => "๐Ÿ™‚ ", Type::Android => "๐Ÿค– ", Type::AOSC => "๐Ÿฑ ", @@ -42,6 +42,7 @@ impl Default for OSConfig<'_> { Type::CachyOS => "๐ŸŽ—๏ธ ", Type::CentOS => "๐Ÿ’  ", Type::Debian => "๐ŸŒ€ ", + Type::Elementary => "๐Ÿ ", Type::DragonFly => "๐Ÿ‰ ", Type::Emscripten => "๐Ÿ”— ", Type::EndeavourOS => "๐Ÿš€ ", @@ -51,6 +52,8 @@ impl Default for OSConfig<'_> { Type::Gentoo => "๐Ÿ—œ๏ธ ", Type::HardenedBSD => "๐Ÿ›ก๏ธ ", Type::Illumos => "๐Ÿฆ ", + Type::Ios => "๐Ÿ“ฑ ", + Type::InstantOS => "โฒ๏ธ ", Type::Kali => "๐Ÿ‰ ", Type::Linux => "๐Ÿง ", Type::Mabox => "๐Ÿ“ฆ ", @@ -67,6 +70,7 @@ impl Default for OSConfig<'_> { Type::openEuler => "๐Ÿฆ‰ ", Type::openSUSE => "๐ŸฆŽ ", Type::OracleLinux => "๐Ÿฆด ", + Type::PikaOS => "๐Ÿค ", Type::Pop => "๐Ÿญ ", Type::Raspbian => "๐Ÿ“ ", Type::Redhat => "๐ŸŽฉ ", @@ -81,12 +85,10 @@ impl Default for OSConfig<'_> { Type::Uos => "๐Ÿฒ ", Type::Void => "๎Š™ ", Type::Windows => "๐ŸชŸ ", + Type::Zorin => "๐Ÿ”น ", // Future symbols. - //aosc => "๏Œ ", - //artix => "๏„ค ", //coreos => "๏Œ… ", //devuan => "๏Œ‡ ", - //elementary => "๏Œ‰ ", //mageia => "๏Œ ", //mandriva => "๏Œ‘ ", //sabayon => "๏Œ— ", diff --git a/src/context.rs b/src/context.rs index f741ea5ab..e82acaa30 100644 --- a/src/context.rs +++ b/src/context.rs @@ -498,10 +498,10 @@ pub enum Detected { } fn home_dir(env: &Env) -> Option { - if cfg!(test) { - if let Some(home) = env.get_env("HOME") { - return Some(PathBuf::from(home)); - } + if cfg!(test) + && let Some(home) = env.get_env("HOME") + { + return Some(PathBuf::from(home)); } utils::home_dir() } diff --git a/src/modules/custom.rs b/src/modules/custom.rs index 1b231d19c..a27582ad6 100644 --- a/src/modules/custom.rs +++ b/src/modules/custom.rs @@ -28,10 +28,11 @@ pub fn module<'a>(name: &str, context: &'a Context) -> Option> { return None; } - if let Some(os) = config.os { - if os != env::consts::OS && !(os == "unix" && cfg!(unix)) { - return None; - } + if let Some(os) = config.os + && os != env::consts::OS + && !(os == "unix" && cfg!(unix)) + { + return None; } if config.require_repo && context.get_repo().is_err() { diff --git a/src/modules/git_status.rs b/src/modules/git_status.rs index 2904011a8..1c9e4fb76 100644 --- a/src/modules/git_status.rs +++ b/src/modules/git_status.rs @@ -348,22 +348,22 @@ fn get_repo_status( let has_ahead_behind = !config.ahead.is_empty() || !config.behind.is_empty(); let has_up_to_date_or_diverged = !config.up_to_date.is_empty() || !config.diverged.is_empty(); - if has_ahead_behind || has_up_to_date_or_diverged { - if let Some(branch_name) = gix_repo.head_name().ok().flatten().and_then(|ref_name| { + if (has_ahead_behind || has_up_to_date_or_diverged) + && let Some(branch_name) = gix_repo.head_name().ok().flatten().and_then(|ref_name| { Vec::from(gix::bstr::BString::from(ref_name)) .into_string() .ok() - }) { - let output = repo.exec_git( - context, - ["for-each-ref", "--format", "%(upstream) %(upstream:track)"] - .into_iter() - .map(ToOwned::to_owned) - .chain(Some(branch_name)), - )?; - if let Some(line) = output.stdout.lines().next() { - repo_status.set_ahead_behind_for_each_ref(line); - } + }) + { + let output = repo.exec_git( + context, + ["for-each-ref", "--format", "%(upstream) %(upstream:track)"] + .into_iter() + .map(ToOwned::to_owned) + .chain(Some(branch_name)), + )?; + if let Some(line) = output.stdout.lines().next() { + repo_status.set_ahead_behind_for_each_ref(line); } } diff --git a/src/modules/gradle.rs b/src/modules/gradle.rs index 7c0030c14..68ea5d594 100644 --- a/src/modules/gradle.rs +++ b/src/modules/gradle.rs @@ -93,10 +93,9 @@ fn get_wrapper_properties_file(context: &Context, recursive: bool) -> Option(context: &'a Context) -> Option> { .inspect_err(|e| log::warn!("Failed to get hostname: {e}")) .ok()?; - //rustc doesn't let you do an "if" and an "if let" in the same if statement - // if this changes in the future this can become a lot cleaner - let mut host = if config.trim_at.is_empty() { - host.as_ref() - } else if let Some(index) = host.find(config.trim_at) { + let mut host = if !config.trim_at.is_empty() + && let Some(index) = host.find(config.trim_at) + { host.split_at(index).0 } else { host.as_ref() diff --git a/src/modules/os.rs b/src/modules/os.rs index 5952f0926..b7951b3af 100644 --- a/src/modules/os.rs +++ b/src/modules/os.rs @@ -338,6 +338,7 @@ mod tests { Type::AIX => "โžฟ ", Type::Alpaquita => "๐Ÿ”” ", Type::Alpine => "๐Ÿ”๏ธ ", + Type::ALTLinux => "โ’ถ ", Type::Amazon => "๐Ÿ™‚ ", Type::Android => "๐Ÿค– ", Type::AOSC => "๐Ÿฑ ", @@ -347,6 +348,7 @@ mod tests { Type::Cygwin => "", Type::Debian => "๐ŸŒ€ ", Type::DragonFly => "๐Ÿ‰ ", + Type::Elementary => "๐Ÿ ", Type::Emscripten => "๐Ÿ”— ", Type::EndeavourOS => "๐Ÿš€ ", Type::Fedora | Type::Nobara | Type::Redhat | Type::RedHatEnterprise => "๐ŸŽฉ ", @@ -355,6 +357,8 @@ mod tests { Type::Gentoo => "๐Ÿ—œ๏ธ ", Type::HardenedBSD => "๐Ÿ›ก๏ธ ", Type::Illumos => "๐Ÿฆ ", + Type::Ios => "๐Ÿ“ฑ ", + Type::InstantOS => "โฒ๏ธ ", Type::Kali => "๐Ÿ‰ ", Type::Linux => "๐Ÿง ", Type::Mabox => "๐Ÿ“ฆ ", @@ -370,6 +374,7 @@ mod tests { Type::openEuler => "๐Ÿฆ‰ ", Type::openSUSE => "๐ŸฆŽ ", Type::OracleLinux => "๐Ÿฆด ", + Type::PikaOS => "๐Ÿค ", Type::Pop => "๐Ÿญ ", Type::Raspbian => "๐Ÿ“ ", Type::Redox => "๐Ÿงช ", @@ -381,6 +386,7 @@ mod tests { Type::Uos => "๐Ÿฒ ", Type::Void => "๎Š™ ", Type::Windows => "๐ŸชŸ ", + Type::Zorin => "๐Ÿ”น ", _ => "", }; } diff --git a/src/modules/rust.rs b/src/modules/rust.rs index dbb065c94..3a5ee58a8 100644 --- a/src/modules/rust.rs +++ b/src/modules/rust.rs @@ -333,19 +333,17 @@ fn find_rust_toolchain_file(context: &Context) -> Option { if context .dir_contents() .is_ok_and(|dir| dir.has_file("rust-toolchain")) + && let Some(toolchain) = read_channel(Path::new("rust-toolchain"), false) { - if let Some(toolchain) = read_channel(Path::new("rust-toolchain"), false) { - return Some(toolchain); - } + return Some(toolchain); } if context .dir_contents() .is_ok_and(|dir| dir.has_file("rust-toolchain.toml")) + && let Some(toolchain) = read_channel(Path::new("rust-toolchain.toml"), true) { - if let Some(toolchain) = read_channel(Path::new("rust-toolchain.toml"), true) { - return Some(toolchain); - } + return Some(toolchain); } let mut dir = &*context.current_dir; @@ -365,13 +363,14 @@ fn extract_toolchain_from_rustup_run_rustc_version(output: Output) -> RustupRunR if let Ok(output) = String::from_utf8(output.stdout) { return RustupRunRustcVersionOutcome::RustcVersion(output); } - } else if let Ok(stderr) = String::from_utf8(output.stderr) { - if stderr.starts_with("error: toolchain '") && stderr.ends_with("' is not installed\n") { - let stderr = stderr - ["error: toolchain '".len()..stderr.len() - "' is not installed\n".len()] - .to_owned(); - return RustupRunRustcVersionOutcome::ToolchainNotInstalled(stderr); - } + } else if let Ok(stderr) = String::from_utf8(output.stderr) + && stderr.starts_with("error: toolchain '") + && stderr.ends_with("' is not installed\n") + { + let stderr = stderr + ["error: toolchain '".len()..stderr.len() - "' is not installed\n".len()] + .to_owned(); + return RustupRunRustcVersionOutcome::ToolchainNotInstalled(stderr); } RustupRunRustcVersionOutcome::Err }