Código de estado
Traducción Beta No Oficial
Esta página fue traducida por PageTurner AI (beta). No está respaldada oficialmente por el proyecto. ¿Encontraste un error? Reportar problema →
Qué hace
Muestra el último código de estado conocido y/o la razón por la que falló el último comando.
Configuración de ejemplo
- 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
Opciones
| 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 |
Plantilla (info)
plantilla predeterminada
{{ .String }}
Propiedades
| 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) |
Plantilla de estado
Cuando uses status_template, emplea if eq .Code 0 para verificar un código de salida exitoso. La propiedad .Error
se usa en un contexto global y no necesariamente indica que el código validado actual sea un valor distinto de cero.
{{ if eq .Code 0 }}\uf00c{{ else }}\uf071{{ end }}
Si prefieres obtener la razón del código de salida en lugar del código en sí, puedes usar la función reason:
{{ if eq .Code 0 }}\uf00c{{ else }}\uf071 {{ reason .Code }}{{ end }}