mirror of
https://github.com/oh-my-fish/theme-bobthefish.git
synced 2024-10-27 20:34:23 +00:00
Added the k8s namespace value to the prompt and the k8s icon to the segment (#208)
This commit is contained in:
parent
1abb331c60
commit
5389a26442
@ -579,10 +579,7 @@ function __bobthefish_prompt_docker -S -d 'Display Docker machine name'
|
||||
echo -ns $DOCKER_MACHINE_NAME ' '
|
||||
end
|
||||
|
||||
function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context'
|
||||
[ "$theme_display_k8s_context" = 'yes' ]
|
||||
or return
|
||||
|
||||
function __bobthefish_k8s_context -S -d 'Get the current k8s context'
|
||||
set -l config_paths "$HOME/.kube/config"
|
||||
[ -n "$KUBECONFIG" ]
|
||||
and set config_paths (string split ':' "$KUBECONFIG") $config_paths
|
||||
@ -595,14 +592,36 @@ function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context'
|
||||
if [ "$key" = 'current-context:' ]
|
||||
set -l context (string trim -c '"\' ' -- $val)
|
||||
[ -z "$context" ]
|
||||
and return
|
||||
and return 1
|
||||
|
||||
__bobthefish_start_segment $color_k8s
|
||||
echo -ns $context ' '
|
||||
echo $context
|
||||
return
|
||||
end
|
||||
end <$file
|
||||
end
|
||||
|
||||
return 1
|
||||
end
|
||||
|
||||
function __bobthefish_k8s_namespace -S -d 'Get the current k8s namespace'
|
||||
kubectl config view --minify --output "jsonpath={..namespace}"
|
||||
end
|
||||
|
||||
function __bobthefish_prompt_k8s_context -S -d 'Show current Kubernetes context'
|
||||
[ "$theme_display_k8s_context" = 'yes' ]
|
||||
or return
|
||||
|
||||
set -l context (__bobthefish_k8s_context)
|
||||
or return
|
||||
|
||||
set -l namespace (__bobthefish_k8s_namespace)
|
||||
|
||||
set -l segment $k8s_glyph " " $context
|
||||
[ -n "$namespace" ]
|
||||
and set segment $segment ":" $namespace
|
||||
|
||||
__bobthefish_start_segment $color_k8s
|
||||
echo -ns $segment " "
|
||||
end
|
||||
|
||||
|
||||
|
@ -25,6 +25,9 @@ function __bobthefish_glyphs -S -d 'Define glyphs used by bobthefish'
|
||||
# Desk glyphs
|
||||
set -x desk_glyph \u25F2
|
||||
|
||||
# Kubernetes glyphs
|
||||
set -x k8s_glyph \u2388 # '⎈'
|
||||
|
||||
# Vagrant glyphs
|
||||
set -x vagrant_running_glyph \u2191 # ↑ 'running'
|
||||
set -x vagrant_poweroff_glyph \u2193 # ↓ 'poweroff'
|
||||
|
Loading…
Reference in New Issue
Block a user