mirror of
https://github.com/Llewellynvdm/starship.git
synced 2024-11-08 14:21:05 +00:00
feat(nix_shell): add symbol to nix-shell module (#1058)
* feat: add nix-shell icon Fixes #1048 * style: make nix-shell bold blue by default It better matches the whole theme around Nix and snowflakes.
This commit is contained in:
parent
8d90baf0eb
commit
7718450311
@ -977,13 +977,14 @@ The module will be shown when inside a nix-shell environment.
|
|||||||
|
|
||||||
### Options
|
### Options
|
||||||
|
|
||||||
| Variable | Default | Description |
|
| Variable | Default | Description |
|
||||||
| ------------ | ------------ | ---------------------------------- |
|
| ------------ | ------------- | ------------------------------------------------- |
|
||||||
| `use_name` | `false` | Display the name of the nix-shell. |
|
| `use_name` | `false` | Display the name of the nix-shell. |
|
||||||
| `impure_msg` | `"impure"` | Customize the "impure" msg. |
|
| `impure_msg` | `"impure"` | Customize the "impure" msg. |
|
||||||
| `pure_msg` | `"pure"` | Customize the "pure" msg. |
|
| `pure_msg` | `"pure"` | Customize the "pure" msg. |
|
||||||
| `style` | `"bold red"` | The style for the module. |
|
| `symbol` | `"❄️ "` | The symbol used before displaying the shell name. |
|
||||||
| `disabled` | `false` | Disables the `nix_shell` module. |
|
| `style` | `"bold blue"` | The style for the module. |
|
||||||
|
| `disabled` | `false` | Disables the `nix_shell` module. |
|
||||||
|
|
||||||
### Example
|
### Example
|
||||||
|
|
||||||
@ -995,6 +996,7 @@ disabled = true
|
|||||||
use_name = true
|
use_name = true
|
||||||
impure_msg = "impure shell"
|
impure_msg = "impure shell"
|
||||||
pure_msg = "pure shell"
|
pure_msg = "pure shell"
|
||||||
|
symbol = "☃️ "
|
||||||
```
|
```
|
||||||
|
|
||||||
## NodeJS
|
## NodeJS
|
||||||
|
@ -9,6 +9,7 @@ pub struct NixShellConfig<'a> {
|
|||||||
pub impure_msg: SegmentConfig<'a>,
|
pub impure_msg: SegmentConfig<'a>,
|
||||||
pub pure_msg: SegmentConfig<'a>,
|
pub pure_msg: SegmentConfig<'a>,
|
||||||
pub style: Style,
|
pub style: Style,
|
||||||
|
pub symbol: SegmentConfig<'a>,
|
||||||
pub disabled: bool,
|
pub disabled: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +19,8 @@ impl<'a> RootModuleConfig<'a> for NixShellConfig<'a> {
|
|||||||
use_name: false,
|
use_name: false,
|
||||||
impure_msg: SegmentConfig::new("impure"),
|
impure_msg: SegmentConfig::new("impure"),
|
||||||
pure_msg: SegmentConfig::new("pure"),
|
pure_msg: SegmentConfig::new("pure"),
|
||||||
style: Color::Red.bold(),
|
style: Color::Blue.bold(),
|
||||||
|
symbol: SegmentConfig::new("❄️ "),
|
||||||
disabled: false,
|
disabled: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
|
|||||||
let config: NixShellConfig = NixShellConfig::try_load(module.config);
|
let config: NixShellConfig = NixShellConfig::try_load(module.config);
|
||||||
|
|
||||||
module.set_style(config.style);
|
module.set_style(config.style);
|
||||||
|
module.create_segment("symbol", &config.symbol);
|
||||||
|
|
||||||
let shell_type = env::var("IN_NIX_SHELL").ok()?;
|
let shell_type = env::var("IN_NIX_SHELL").ok()?;
|
||||||
let shell_type_segment: SegmentConfig = match shell_type.as_ref() {
|
let shell_type_segment: SegmentConfig = match shell_type.as_ref() {
|
||||||
|
@ -28,7 +28,7 @@ fn pure_shell() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Red.bold().paint("pure"));
|
let expected = format!("via {} ", Color::Blue.bold().paint("❄️ pure"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -40,7 +40,7 @@ fn impure_shell() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Red.bold().paint("impure"));
|
let expected = format!("via {} ", Color::Blue.bold().paint("❄️ impure"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -52,7 +52,7 @@ fn lorri_shell() -> io::Result<()> {
|
|||||||
.output()?;
|
.output()?;
|
||||||
let actual = String::from_utf8(output.stdout).unwrap();
|
let actual = String::from_utf8(output.stdout).unwrap();
|
||||||
|
|
||||||
let expected = format!("via {} ", Color::Red.bold().paint("impure"));
|
let expected = format!("via {} ", Color::Blue.bold().paint("❄️ impure"));
|
||||||
assert_eq!(expected, actual);
|
assert_eq!(expected, actual);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user