Skip to content

Instantly share code, notes, and snippets.

@hongqn
Created July 28, 2020 11:27
Show Gist options
  • Save hongqn/5ceec2d50e2820d91c60349649786bd2 to your computer and use it in GitHub Desktop.
Save hongqn/5ceec2d50e2820d91c60349649786bd2 to your computer and use it in GitHub Desktop.
diff --git a/.p10k.zsh b/.p10k.zsh
index 71ef1ce..ccaf60d 100644
--- a/.p10k.zsh
+++ b/.p10k.zsh
@@ -1110,7 +1110,7 @@
#############[ kubecontext: current kubernetes context (https://kubernetes.io/) ]#############
# Show kubecontext only when the the command you are typing invokes one of these tools.
# Tip: Remove the next line to always show kubecontext.
- typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito'
+ typeset -g POWERLEVEL9K_KUBECONTEXT_SHOW_ON_COMMAND='kubectl|helm|kubens|kubectx|oc|istioctl|kogito|lain'
# Kubernetes context classes for the purpose of using different colors, icons and expansions with
# different contexts.
@@ -1194,6 +1194,16 @@
# Custom prefix.
# typeset -g POWERLEVEL9K_KUBECONTEXT_PREFIX='%fat '
+ function prompt_kubecontext() {
+ local cluster
+ if [ -L ~/.kube/config ]; then
+ cluster=$(readlink ~/.kube/config| xargs basename | cut -d- -f2)
+ else
+ cluster="NOTSET"
+ fi
+ p10k segment -f ${POWERLEVEL9K_KUBECONTEXT_DEFAULT_FOREGROUND} -i '⎈' -t "${cluster} "
+ }
+
################[ terraform: terraform workspace (https://www.terraform.io) ]#################
# POWERLEVEL9K_TERRAFORM_CLASSES is an array with even number of elements. The first element
# in each pair defines a pattern against which the current terraform workspace gets matched.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment