Skip to content

Commit

Permalink
Added the k8s namespace value to the prompt and the k8s icon to the s…
Browse files Browse the repository at this point in the history
…egment (#208)
  • Loading branch information
morozov authored and bobthecow committed Jul 1, 2019
1 parent 1abb331 commit 5389a26
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
33 changes: 26 additions & 7 deletions fish_prompt.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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


Expand Down
3 changes: 3 additions & 0 deletions functions/__bobthefish_glyphs.fish
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit 5389a26

Please sign in to comment.