From 740150da19ee745fd6cf8b442f5dc5aca293a753 Mon Sep 17 00:00:00 2001 From: Alexander Olsson Date: Sat, 29 Feb 2020 18:39:32 +0100 Subject: [PATCH] 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. --- README.md | 1 + fish_prompt.fish | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 43ed9e4..dd78e50 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/fish_prompt.fish b/fish_prompt.fish index 29f8753..a1217d7 100644 --- a/fish_prompt.fish +++ b/fish_prompt.fish @@ -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" ]