kubectx.plugin.zsh 368 B

12345678910111213
  1. typeset -g -A kubectx_mapping
  2. function kubectx_prompt_info() {
  3. (( $+commands[kubectl] )) || return
  4. local current_ctx=$(kubectl config current-context 2> /dev/null)
  5. [[ -n "$current_ctx" ]] || return
  6. # use value in associative array if it exists
  7. # otherwise fall back to the context name
  8. echo "${kubectx_mapping[$current_ctx]:-${current_ctx:gs/%/%%}}"
  9. }