summaryrefslogtreecommitdiffstats
path: root/zsh/oh-my-zsh/plugins/kubectx/kubectx.plugin.zsh
diff options
context:
space:
mode:
Diffstat (limited to 'zsh/oh-my-zsh/plugins/kubectx/kubectx.plugin.zsh')
-rw-r--r--zsh/oh-my-zsh/plugins/kubectx/kubectx.plugin.zsh13
1 files changed, 13 insertions, 0 deletions
diff --git a/zsh/oh-my-zsh/plugins/kubectx/kubectx.plugin.zsh b/zsh/oh-my-zsh/plugins/kubectx/kubectx.plugin.zsh
new file mode 100644
index 0000000..6096fee
--- /dev/null
+++ b/zsh/oh-my-zsh/plugins/kubectx/kubectx.plugin.zsh
@@ -0,0 +1,13 @@
+typeset -g -A kubectx_mapping
+
+function kubectx_prompt_info() {
+ (( $+commands[kubectl] )) || return
+
+ local current_ctx=$(kubectl config current-context 2> /dev/null)
+
+ [[ -n "$current_ctx" ]] || return
+
+ # use value in associative array if it exists
+ # otherwise fall back to the context name
+ echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}"
+}