feat(status): add the status module (#1651)

* add the exit code module

this allows to display more precisely the last command exit code
and to configure starship to not change the last charcter of the
prompt even in case of failure. It is disabled by default, because
it seems a bit redundant with the character module in its default
configuration.

* rename exit_code module to status

* Enforce a default disabled=true 

In the outer places, we only check for the disabled flag in the config toml file, only when this is loaded into the real config struct, we see the default. And if the default is true, we have to abort at that place. For status and hg_branch that wasn't so. I also commented the rest

* fix spaces in markdown table for status module

* Add a tip that status module is disabled by default

Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>

* Remove unrelated changes for default disabled=true

Co-authored-by: Gaëtan Lehmann <gaetan.lehmann@gmail.com>
Co-authored-by: Thomas O'Donnell <andytom@users.noreply.github.com>
This commit is contained in:
Jan Katins
2020-09-26 00:04:51 +02:00
committed by GitHub
parent 17687be1cb
commit ffb1345052
7 changed files with 192 additions and 0 deletions
+46
View File
@@ -217,6 +217,7 @@ $line_break\
$jobs\
$battery\
$time\
$status\
$character"""
```
@@ -2084,6 +2085,51 @@ The module will be shown if any of the following conditions are met:
format = "via [🏎 $version](red bold)"
```
## Status
The `status` module displays the exit code of the previous command.
The module will be shown only if the exit code is not `0`.
::: tip
This module is disabled by default.
To enable it, set `disabled` to `false` in your configuration file.
:::
### Options
| Variable | Default | Description |
| ---------- | ----------------------------- | ------------------------------------------------------ |
| `format` | `[$symbol$status]($style) ` | The format of the module |
| `symbol` | `"✖"` | A format string representing the symbol for the status |
| `style` | `"bold red"` | The style for the module. |
| `disabled` | `true` | Disables the `status` module. |
### Variables
| Variable | Example | Description |
| -------- | -------- | ------------------------------------ |
| status | `127` | The exit code of the last command |
| symbol | | Mirrors the value of option `symbol` |
| style\* | | Mirrors the value of option `style` |
\*: This variable can only be used as a part of a style string
### Example
```toml
# ~/.config/starship.toml
[status]
style = "bg:blue"
symbol = "💣 "
format = "[\\[$symbol$status\\]]($style) "
disabled = false
```
## Terraform
The `terraform` module shows the currently selected terraform workspace and version.