Statuscode
Onofficiรซle Beta-vertaling
Deze pagina is vertaald door PageTurner AI (beta). Niet officieel goedgekeurd door het project. Een fout gevonden? Probleem melden โ
Watโ
Toont de laatst bekende statuscode en/of de reden waarom het laatste commando is mislukt.
Voorbeeldconfiguratieโ
- json
- yaml
- toml
{
"type": "status",
"style": "diamond",
"foreground": "#ffffff",
"background": "#00897b",
"background_templates": [
"{{ if .Error }}#e91e63{{ end }}"
],
"trailing_diamond": "๎ด",
"template": "<#193549>๎ฐ</> ๎บ ",
"options": {
"always_enabled": true
}
}
type: status
style: diamond
foreground: "#ffffff"
background: "#00897b"
background_templates:
- "{{ if .Error }}#e91e63{{ end }}"
trailing_diamond: ๎ด
template: "<#193549>๎ฐ</> ๎บ "
options:
always_enabled: true
type = "status"
style = "diamond"
foreground = "#ffffff"
background = "#00897b"
background_templates = [ "{{ if .Error }}#e91e63{{ end }}" ]
trailing_diamond = "๎ด"
template = "<#193549>๎ฐ</> ๎บ "
[options]
always_enabled = true
Optiesโ
| Name | Type | Default | Description |
|---|---|---|---|
always_enabled | boolean | false | always show the status |
status_template | string | {{ .Code }} | template used to render an individual status code |
status_separator | string | | | used to separate multiple statuses when $PIPESTATUS is available |
Template (informatie)โ
standaardsjabloon
{{ .String }}
Eigenschappenโ
| Name | Type | Description |
|---|---|---|
.Code | number | the last known exit code (command or pipestatus) |
.String | string | the formatted status codes using status_template and status_separator |
.Error | boolean | true if one of the commands has an error (validates on command status and pipestatus) |
Statussjabloonโ
Wanneer je status_template gebruikt, controleer dan met if eq .Code 0 op een succesvolle afsluitcode. De .Error-eigenschap
wordt in een globale context gebruikt en geeft niet noodzakelijk aan dat de huidige gevalideerde code een niet-nul waarde is.
{{ if eq .Code 0 }}\uf00c{{ else }}\uf071{{ end }}
Als je de reden voor de afsluitcode wilt in plaats van de code zelf, kun je de reason-functie gebruiken:
{{ if eq .Code 0 }}\uf00c{{ else }}\uf071 {{ reason .Code }}{{ end }}