mirror of
https://github.com/starship/starship.git
synced 2024-11-22 08:14:10 +01:00
feat(status): add {success,failure}_style
options
This commit is contained in:
parent
da804d6e22
commit
657551f4aa
12
.github/config-schema.json
vendored
12
.github/config-schema.json
vendored
@ -5983,6 +5983,18 @@
|
|||||||
"default": "bold red",
|
"default": "bold red",
|
||||||
"type": "string"
|
"type": "string"
|
||||||
},
|
},
|
||||||
|
"success_style": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"failure_style": {
|
||||||
|
"type": [
|
||||||
|
"string",
|
||||||
|
"null"
|
||||||
|
]
|
||||||
|
},
|
||||||
"map_symbol": {
|
"map_symbol": {
|
||||||
"default": false,
|
"default": false,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
|
@ -4281,6 +4281,8 @@ To enable it, set `disabled` to `false` in your configuration file.
|
|||||||
| `sigint_symbol` | `'🧱'` | The symbol displayed on SIGINT (Ctrl + c) |
|
| `sigint_symbol` | `'🧱'` | The symbol displayed on SIGINT (Ctrl + c) |
|
||||||
| `signal_symbol` | `'⚡'` | The symbol displayed on any signal |
|
| `signal_symbol` | `'⚡'` | The symbol displayed on any signal |
|
||||||
| `style` | `'bold red'` | The style for the module. |
|
| `style` | `'bold red'` | The style for the module. |
|
||||||
|
| `success_style` | | The style used on program success (defaults to `style` if unset). |
|
||||||
|
| `failure_style` | | The style used on program failure (defaults to `style` if unset). |
|
||||||
| `recognize_signal_code` | `true` | Enable signal mapping from exit code |
|
| `recognize_signal_code` | `true` | Enable signal mapping from exit code |
|
||||||
| `map_symbol` | `false` | Enable symbols mapping from exit code |
|
| `map_symbol` | `false` | Enable symbols mapping from exit code |
|
||||||
| `pipestatus` | `false` | Enable pipestatus reporting |
|
| `pipestatus` | `false` | Enable pipestatus reporting |
|
||||||
@ -4292,7 +4294,7 @@ To enable it, set `disabled` to `false` in your configuration file.
|
|||||||
### Variables
|
### Variables
|
||||||
|
|
||||||
| Variable | Example | Description |
|
| Variable | Example | Description |
|
||||||
| -------------- | ------- | ------------------------------------------------------------------------------------------ |
|
| -------------- | ------- | -------------------------------------------------------------------------------------------- |
|
||||||
| status | `127` | The exit code of the last command |
|
| status | `127` | The exit code of the last command |
|
||||||
| hex_status | `0x7F` | The exit code of the last command in hex |
|
| hex_status | `0x7F` | The exit code of the last command in hex |
|
||||||
| int | `127` | The exit code of the last command |
|
| int | `127` | The exit code of the last command |
|
||||||
@ -4302,7 +4304,7 @@ To enable it, set `disabled` to `false` in your configuration file.
|
|||||||
| maybe_int | `7` | Contains the exit code number when no meaning has been found |
|
| maybe_int | `7` | Contains the exit code number when no meaning has been found |
|
||||||
| pipestatus | | Rendering of in pipeline programs' exit codes, this is only available in pipestatus_format |
|
| pipestatus | | Rendering of in pipeline programs' exit codes, this is only available in pipestatus_format |
|
||||||
| symbol | | Mirrors the value of option `symbol` |
|
| symbol | | Mirrors the value of option `symbol` |
|
||||||
| style\* | | Mirrors the value of option `style` |
|
| style\* | | Mirrors the value of option `success_style` on program success and `failure_style` otherwise |
|
||||||
|
|
||||||
*: This variable can only be used as a part of a style string
|
*: This variable can only be used as a part of a style string
|
||||||
|
|
||||||
|
@ -16,6 +16,10 @@ pub struct StatusConfig<'a> {
|
|||||||
pub sigint_symbol: &'a str,
|
pub sigint_symbol: &'a str,
|
||||||
pub signal_symbol: &'a str,
|
pub signal_symbol: &'a str,
|
||||||
pub style: &'a str,
|
pub style: &'a str,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub success_style: Option<&'a str>,
|
||||||
|
#[serde(skip_serializing_if = "Option::is_none")]
|
||||||
|
pub failure_style: Option<&'a str>,
|
||||||
pub map_symbol: bool,
|
pub map_symbol: bool,
|
||||||
pub recognize_signal_code: bool,
|
pub recognize_signal_code: bool,
|
||||||
pub pipestatus: bool,
|
pub pipestatus: bool,
|
||||||
@ -37,6 +41,8 @@ impl<'a> Default for StatusConfig<'a> {
|
|||||||
sigint_symbol: "🧱",
|
sigint_symbol: "🧱",
|
||||||
signal_symbol: "⚡",
|
signal_symbol: "⚡",
|
||||||
style: "bold red",
|
style: "bold red",
|
||||||
|
success_style: None,
|
||||||
|
failure_style: None,
|
||||||
map_symbol: false,
|
map_symbol: false,
|
||||||
recognize_signal_code: true,
|
recognize_signal_code: true,
|
||||||
pipestatus: false,
|
pipestatus: false,
|
||||||
|
@ -158,7 +158,12 @@ fn format_exit_code<'a>(
|
|||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.map_style(|variable| match variable {
|
.map_style(|variable| match variable {
|
||||||
"style" => Some(Ok(config.style)),
|
"style" => Some(Ok(if exit_code_int == 0 {
|
||||||
|
config.success_style
|
||||||
|
} else {
|
||||||
|
config.failure_style
|
||||||
|
}
|
||||||
|
.unwrap_or(config.style))),
|
||||||
_ => None,
|
_ => None,
|
||||||
})
|
})
|
||||||
.map(|variable| match variable {
|
.map(|variable| match variable {
|
||||||
|
Loading…
Reference in New Issue
Block a user