Make displaying the k8s namespace optional

Invoking the `kubectl` command can be expensive, and since there's not a
lot of time to play with when rendering the prompt without it feeling
slugging, make the namespace fetching optional.
pull/214/head
Alexander Olsson 4 years ago
parent 94cb2bb8f0
commit 740150da19
No known key found for this signature in database
GPG Key ID: E4BD870C390D7556

@ -121,6 +121,7 @@ set -g theme_newline_prompt '$ '
- `theme_display_vagrant`. This feature is disabled by default, use `yes` to display Vagrant status in your prompt. Please note that only the VirtualBox and VMWare providers are supported.
- `theme_display_vi`. By default the vi mode indicator will be shown if vi or hybrid key bindings are enabled. Use `no` to hide the indicator, or `yes` to show the indicator.
- `theme_display_k8s_context`. This feature is disabled by default. Use `yes` to show the current kubernetes context (`> kubectl config current-context`).
- `theme_display_k8s_namespace`. This feature is disabled by default. Use `yes` to show the current kubernetes namespace.
- `theme_display_user`. If set to `yes`, display username always, if set to `ssh`, only when an SSH-Session is detected, if set to no, never.
- `theme_display_hostname`. Same behaviour as `theme_display_user`.
- `theme_show_exit_status`. Set this option to `yes` to have the prompt show the last exit code if it was non_zero instead of just the exclamation mark.

@ -28,6 +28,7 @@
# set -g theme_display_vagrant yes
# set -g theme_display_docker_machine no
# set -g theme_display_k8s_context yes
# set -g theme_display_k8s_namespace no
# set -g theme_display_hg yes
# set -g theme_display_virtualenv no
# set -g theme_display_ruby no
@ -627,7 +628,8 @@ function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context'
set -l context (__bobthefish_k8s_context)
or return
set -l namespace (__bobthefish_k8s_namespace)
[ "$theme_display_k8s_namespace" = 'yes' ]
and set -l namespace (__bobthefish_k8s_namespace)
set -l segment $k8s_glyph " " $context
[ -n "$namespace" ]

Loading…
Cancel
Save