diff --git a/docs/themes-list/powerline-base.rst b/docs/themes-list/powerline-base.rst index b3907c6b..faa1af34 100644 --- a/docs/themes-list/powerline-base.rst +++ b/docs/themes-list/powerline-base.rst @@ -76,6 +76,7 @@ The contents of the prompt can be "reordered", all the "segments" (every piece o * ``in_toolbox`` - Show identifier if running inside a `toolbox `_ * ``in_vim`` - Show identifier if running in ``:terminal`` from vim * ``k8s_context`` - Show current kubernetes context +* ``k8s_namespace`` - Show current kubernetes namespace * ``last_status`` - Exit status of last run command * ``python_venv`` - Python virtual environment information (\ ``virtualenv``\ , ``venv`` and ``conda`` supported) diff --git a/themes/base.theme.bash b/themes/base.theme.bash index a1520397..bc4718f2 100644 --- a/themes/base.theme.bash +++ b/themes/base.theme.bash @@ -437,6 +437,10 @@ function k8s_context_prompt { echo -e "$(kubectl config current-context 2> /dev/null)" } +function k8s_namespace_prompt { + echo -e "$(kubectl config view --minify --output 'jsonpath={..namespace}' 2> /dev/null)" +} + function virtualenv_prompt { if [[ -n "$VIRTUAL_ENV" ]]; then virtualenv=$(basename "$VIRTUAL_ENV") diff --git a/themes/powerline-multiline/powerline-multiline.theme.bash b/themes/powerline-multiline/powerline-multiline.theme.bash index 05c04987..48a1243e 100644 --- a/themes/powerline-multiline/powerline-multiline.theme.bash +++ b/themes/powerline-multiline/powerline-multiline.theme.bash @@ -55,6 +55,9 @@ TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="❲t❳ "} KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_CONTEXT_COLOR:=26} +KUBERNETES_NAMESPACE_THEME_CHAR=${POWERLINE_KUBERNETES_NAMESPACE_CHAR:="⎈ "} +KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_NAMESPACE_COLOR:=64} + AWS_PROFILE_CHAR=${POWERLINE_AWS_PROFILE_CHAR:="❲aws❳ "} AWS_PROFILE_PROMPT_COLOR=${POWERLINE_AWS_PROFILE_COLOR:=208} diff --git a/themes/powerline-naked/powerline-naked.theme.bash b/themes/powerline-naked/powerline-naked.theme.bash index 417ae71a..2fb4137e 100644 --- a/themes/powerline-naked/powerline-naked.theme.bash +++ b/themes/powerline-naked/powerline-naked.theme.bash @@ -50,6 +50,9 @@ TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="❲t❳ "} KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_CONTEXT_COLOR:=26} +KUBERNETES_NAMESPACE_THEME_CHAR=${POWERLINE_KUBERNETES_NAMESPACE_CHAR:="⎈ "} +KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_NAMESPACE_COLOR:=64} + AWS_PROFILE_CHAR=${POWERLINE_AWS_PROFILE_CHAR:="❲aws❳ "} AWS_PROFILE_PROMPT_COLOR=${POWERLINE_AWS_PROFILE_COLOR:=208} diff --git a/themes/powerline-plain/powerline-plain.theme.bash b/themes/powerline-plain/powerline-plain.theme.bash index 0b8f4f56..6ff68e8f 100644 --- a/themes/powerline-plain/powerline-plain.theme.bash +++ b/themes/powerline-plain/powerline-plain.theme.bash @@ -47,6 +47,9 @@ TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="❲t❳ "} KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_CONTEXT_COLOR:=26} +KUBERNETES_NAMESPACE_THEME_CHAR=${POWERLINE_KUBERNETES_NAMESPACE_CHAR:="⎈ "} +KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_NAMESPACE_COLOR:=60} + AWS_PROFILE_CHAR=${POWERLINE_AWS_PROFILE_CHAR:="❲aws❳ "} AWS_PROFILE_PROMPT_COLOR=${POWERLINE_AWS_PROFILE_COLOR:=208} diff --git a/themes/powerline/powerline.base.bash b/themes/powerline/powerline.base.bash index a3f71642..98bcd82c 100644 --- a/themes/powerline/powerline.base.bash +++ b/themes/powerline/powerline.base.bash @@ -85,6 +85,16 @@ function __powerline_k8s_context_prompt() { [[ -n "${kubernetes_context}" ]] && echo "${KUBERNETES_CONTEXT_THEME_CHAR}${kubernetes_context}|${KUBERNETES_CONTEXT_THEME_PROMPT_COLOR}" } +function __powerline_k8s_namespace_prompt() { + local kubernetes_namespace="" + + if _command_exists kubectl; then + kubernetes_namespace="$(k8s_namespace_prompt)" + fi + + [[ -n "${kubernetes_namespace}" ]] && echo "${KUBERNETES_NAMESPACE_THEME_CHAR}${kubernetes_namespace}|${KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR}" +} + function __powerline_python_venv_prompt() { set +u local python_venv="" diff --git a/themes/powerline/powerline.theme.bash b/themes/powerline/powerline.theme.bash index 6b45d2d0..d7ac77ed 100644 --- a/themes/powerline/powerline.theme.bash +++ b/themes/powerline/powerline.theme.bash @@ -52,6 +52,9 @@ TERRAFORM_CHAR=${POWERLINE_TERRAFORM_CHAR:="❲t❳ "} KUBERNETES_CONTEXT_THEME_CHAR=${POWERLINE_KUBERNETES_CONTEXT_CHAR:="⎈ "} KUBERNETES_CONTEXT_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_CONTEXT_COLOR:=26} +KUBERNETES_NAMESPACE_THEME_CHAR=${POWERLINE_KUBERNETES_NAMESPACE_CHAR:="⎈ "} +KUBERNETES_NAMESPACE_THEME_PROMPT_COLOR=${POWERLINE_KUBERNETES_NAMESPACE_COLOR:=64} + AWS_PROFILE_CHAR=${POWERLINE_AWS_PROFILE_CHAR:="❲aws❳ "} AWS_PROFILE_PROMPT_COLOR=${POWERLINE_AWS_PROFILE_COLOR:=208}