1
0
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:
Bernardo Meurer 2020-04-07 09:35:18 -07:00 committed by GitHub
parent 8d90baf0eb
commit 7718450311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 11 deletions

View File

@ -977,13 +977,14 @@ The module will be shown when inside a nix-shell environment.
### Options
| Variable | Default | Description |
| ------------ | ------------ | ---------------------------------- |
| `use_name` | `false` | Display the name of the nix-shell. |
| `impure_msg` | `"impure"` | Customize the "impure" msg. |
| `pure_msg` | `"pure"` | Customize the "pure" msg. |
| `style` | `"bold red"` | The style for the module. |
| `disabled` | `false` | Disables the `nix_shell` module. |
| Variable | Default | Description |
| ------------ | ------------- | ------------------------------------------------- |
| `use_name` | `false` | Display the name of the nix-shell. |
| `impure_msg` | `"impure"` | Customize the "impure" msg. |
| `pure_msg` | `"pure"` | Customize the "pure" msg. |
| `symbol` | `"❄️ "` | The symbol used before displaying the shell name. |
| `style` | `"bold blue"` | The style for the module. |
| `disabled` | `false` | Disables the `nix_shell` module. |
### Example
@ -995,6 +996,7 @@ disabled = true
use_name = true
impure_msg = "impure shell"
pure_msg = "pure shell"
symbol = "☃️ "
```
## NodeJS

View File

@ -9,6 +9,7 @@ pub struct NixShellConfig<'a> {
pub impure_msg: SegmentConfig<'a>,
pub pure_msg: SegmentConfig<'a>,
pub style: Style,
pub symbol: SegmentConfig<'a>,
pub disabled: bool,
}
@ -18,7 +19,8 @@ impl<'a> RootModuleConfig<'a> for NixShellConfig<'a> {
use_name: false,
impure_msg: SegmentConfig::new("impure"),
pure_msg: SegmentConfig::new("pure"),
style: Color::Red.bold(),
style: Color::Blue.bold(),
symbol: SegmentConfig::new("❄️ "),
disabled: false,
}
}

View File

@ -27,6 +27,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
let config: NixShellConfig = NixShellConfig::try_load(module.config);
module.set_style(config.style);
module.create_segment("symbol", &config.symbol);
let shell_type = env::var("IN_NIX_SHELL").ok()?;
let shell_type_segment: SegmentConfig = match shell_type.as_ref() {

View File

@ -28,7 +28,7 @@ fn pure_shell() -> io::Result<()> {
.output()?;
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);
Ok(())
}
@ -40,7 +40,7 @@ fn impure_shell() -> io::Result<()> {
.output()?;
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);
Ok(())
}
@ -52,7 +52,7 @@ fn lorri_shell() -> io::Result<()> {
.output()?;
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);
Ok(())
}