Kubectl Context
Whatโ
Display the currently active Kubernetes context name and namespace name.
Sample Configurationโ
- json
- yaml
- toml
{
"type": "kubectl",
"style": "powerline",
"powerline_symbol": "๎ฐ",
"foreground": "#000000",
"background": "#ebcc34",
"template": " ๏ดฑ {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}} ",
"properties": {
"context_aliases": {
"arn:aws:eks:eu-west-1:1234567890:cluster/posh": "posh"
}
}
}
type: kubectl
style: powerline
powerline_symbol: ๎ฐ
foreground: "#000000"
background: "#ebcc34"
template: " ๏ดฑ {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}} "
properties:
context_aliases:
arn:aws:eks:eu-west-1:1234567890:cluster/posh: posh
type = "kubectl"
style = "powerline"
powerline_symbol = "๎ฐ"
foreground = "#000000"
background = "#ebcc34"
template = " ๏ดฑ {{.Context}}{{if .Namespace}} :: {{.Namespace}}{{end}} "
[properties.context_aliases]
"arn:aws:eks:eu-west-1:1234567890:cluster/posh" = "posh"
Propertiesโ
Name | Type | Description |
---|---|---|
display_error | boolean | show the error context when failing to retrieve the kubectl information - defaults to false |
parse_kubeconfig | boolean | parse kubeconfig files instead of calling out to kubectl to improve performance - defaults to false |
context_aliases | object | custom context names |
Template (info)โ
default template
{{ .Context }}{{ if .Namespace }} :: {{ .Namespace }}{{ end }}
Propertiesโ
Name | Type | Description |
---|---|---|
.Context | string | the current kubectl context |
.Namespace | string | the current kubectl context namespace |
.User | string | the current kubectl context user |
.Cluster | string | the current kubectl context cluster |
tip
It is common for the Kubernetes "default" namespace to be used when no namespace is provided. If you want your prompt to render an empty current namespace using the word "default", you can use something like this for the template:
{{.Context}} :: {{if .Namespace}}{{.Namespace}}{{else}}default{{end}}