Direct naar hoofdinhoud

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โ€‹

{
"type": "status",
"style": "diamond",
"foreground": "#ffffff",
"background": "#00897b",
"background_templates": [
"{{ if .Error }}#e91e63{{ end }}"
],
"trailing_diamond": "๎‚ด",
"template": "<#193549>๎‚ฐ</> ๎ˆบ ",
"options": {
"always_enabled": true
}
}

Optiesโ€‹

NameTypeDefaultDescription
always_enabledbooleanfalsealways show the status
status_templatestring{{ .Code }}template used to render an individual status code
status_separatorstring|used to separate multiple statuses when $PIPESTATUS is available

Template (informatie)โ€‹

standaardsjabloon
 {{ .String }}

Eigenschappenโ€‹

NameTypeDescription
.Codenumberthe last known exit code (command or pipestatus)
.Stringstringthe formatted status codes using status_template and status_separator
.Errorbooleantrue 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 }}