aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorromkatv <roman.perepelitsa@gmail.com>2020-01-26 13:45:56 +0300
committerromkatv <roman.perepelitsa@gmail.com>2020-01-26 13:45:56 +0300
commit5e42c4c930d63530d3547fc5b7f7cbeb619f0def (patch)
tree62b7f4e3aa5bc4c5fc6300c5ffa335af9a48ac2a
parent9c21f4b2736e3c61c90ae61aa585f5edd7df3580 (diff)
add P9K_KUBECONTEXT_USER
-rw-r--r--config/p10k-classic.zsh2
-rw-r--r--config/p10k-lean-8colors.zsh2
-rw-r--r--config/p10k-lean.zsh2
-rw-r--r--config/p10k-rainbow.zsh2
-rw-r--r--internal/p10k.zsh20
5 files changed, 20 insertions, 8 deletions
diff --git a/config/p10k-classic.zsh b/config/p10k-classic.zsh
index 1e966cbf..c2af751e 100644
--- a/config/p10k-classic.zsh
+++ b/config/p10k-classic.zsh
@@ -865,6 +865,8 @@
# - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
# in the output of `kubectl config get-contexts`. If there is no
# namespace, the parameter is set to "default".
+ # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
+ # output of `kubectl config get-contexts`.
#
# If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
# the following extra parameters are available:
diff --git a/config/p10k-lean-8colors.zsh b/config/p10k-lean-8colors.zsh
index 04ac7e90..f32d82fc 100644
--- a/config/p10k-lean-8colors.zsh
+++ b/config/p10k-lean-8colors.zsh
@@ -838,6 +838,8 @@
# - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
# in the output of `kubectl config get-contexts`. If there is no
# namespace, the parameter is set to "default".
+ # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
+ # output of `kubectl config get-contexts`.
#
# If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
# the following extra parameters are available:
diff --git a/config/p10k-lean.zsh b/config/p10k-lean.zsh
index a7c3e369..30846e52 100644
--- a/config/p10k-lean.zsh
+++ b/config/p10k-lean.zsh
@@ -838,6 +838,8 @@
# - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
# in the output of `kubectl config get-contexts`. If there is no
# namespace, the parameter is set to "default".
+ # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
+ # output of `kubectl config get-contexts`.
#
# If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
# the following extra parameters are available:
diff --git a/config/p10k-rainbow.zsh b/config/p10k-rainbow.zsh
index 18725ae0..658c2b1f 100644
--- a/config/p10k-rainbow.zsh
+++ b/config/p10k-rainbow.zsh
@@ -897,6 +897,8 @@
# - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
# in the output of `kubectl config get-contexts`. If there is no
# namespace, the parameter is set to "default".
+ # - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
+ # output of `kubectl config get-contexts`.
#
# If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
# the following extra parameters are available:
diff --git a/internal/p10k.zsh b/internal/p10k.zsh
index 1da83dc8..7469ba8b 100644
--- a/internal/p10k.zsh
+++ b/internal/p10k.zsh
@@ -3836,7 +3836,8 @@ prompt_kubecontext() {
(( $+commands[kubectl] )) || return
if ! _p9k_cache_stat_get $0 ${(s.:.)${KUBECONFIG:-$HOME/.kube/config}}; then
- local name namespace cluster cloud_name cloud_account cloud_zone cloud_cluster text state
+ local name namespace cluster user cloud_name cloud_account cloud_zone cloud_cluster text state
+ local -a match
() {
local cfg && cfg=(${(f)"$(kubectl config view -o=yaml 2>/dev/null)"}) || return
local ctx=(${(@M)cfg:#current-context: [^\"\'\|\>]*})
@@ -3856,6 +3857,8 @@ prompt_kubecontext() {
cluster=$match[1]
elif [[ $line == (#b)' namespace: '([^\"\'\|\>]*) ]]; then
namespace=$match[1]
+ elif [[ $line == (#b)' user: '([^\"\'\|\>]*) ]]; then
+ user=$match[1]
fi
done
}
@@ -3895,18 +3898,19 @@ prompt_kubecontext() {
fi
done
fi
- _p9k_cache_stat_set "$name" "$namespace" "$cluster" "$cloud_name" "$cloud_account" "$cloud_zone" "$cloud_cluster" "$text" "$state"
+ _p9k_cache_stat_set "$name" "$namespace" "$cluster" "$user" "$cloud_name" "$cloud_account" "$cloud_zone" "$cloud_cluster" "$text" "$state"
fi
typeset -g P9K_KUBECONTEXT_NAME=$_p9k_cache_val[1]
typeset -g P9K_KUBECONTEXT_NAMESPACE=$_p9k_cache_val[2]
typeset -g P9K_KUBECONTEXT_CLUSTER=$_p9k_cache_val[3]
- typeset -g P9K_KUBECONTEXT_CLOUD_NAME=$_p9k_cache_val[4]
- typeset -g P9K_KUBECONTEXT_CLOUD_ACCOUNT=$_p9k_cache_val[5]
- typeset -g P9K_KUBECONTEXT_CLOUD_ZONE=$_p9k_cache_val[6]
- typeset -g P9K_KUBECONTEXT_CLOUD_CLUSTER=$_p9k_cache_val[7]
- [[ -n $_p9k_cache_val[8] ]] || return
- _p9k_prompt_segment $0$_p9k_cache_val[9] magenta white KUBERNETES_ICON 0 '' "${_p9k_cache_val[8]//\%/%%}"
+ typeset -g P9K_KUBECONTEXT_USER=$_p9k_cache_val[4]
+ typeset -g P9K_KUBECONTEXT_CLOUD_NAME=$_p9k_cache_val[5]
+ typeset -g P9K_KUBECONTEXT_CLOUD_ACCOUNT=$_p9k_cache_val[6]
+ typeset -g P9K_KUBECONTEXT_CLOUD_ZONE=$_p9k_cache_val[7]
+ typeset -g P9K_KUBECONTEXT_CLOUD_CLUSTER=$_p9k_cache_val[8]
+ [[ -n $_p9k_cache_val[9] ]] || return
+ _p9k_prompt_segment $0$_p9k_cache_val[10] magenta white KUBERNETES_ICON 0 '' "${_p9k_cache_val[9]//\%/%%}"
}
_p9k_prompt_kubecontext_init() {