Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding in support for kubernetes context prompt #8480

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions plugins/kubectl/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,20 @@ To use it, add `kubectl` to the plugins array in your zshrc file:
plugins=(... kubectl)
```

## Theme

The plugin creates an `kctx_prompt_info` function that you can use in your theme which displays your current kubernetes context using `kccc` alias.. It uses two variables to
control how that is shown:

- ZSH_THEME_KCTX_PREFIX: sets the prefix of your current context. Defaults to `<kctx:`.

- ZSH_THEME_KCTX_SUFFIX: sets the suffix of your current context. Defaults to `>`.

## Plugin options

* Set `HIDE_KTCX_PROMPT=true` in your zshrc file if you want to prevent the plugin from modifying your RPROMPT. Some themes might overwrite the value of RPROMPT instead of
appending to it, so they'll need to be fixed to see the Kubernetes context prompt.

## Aliases

| Alias | Command | Description |
Expand Down
10 changes: 10 additions & 0 deletions plugins/kubectl/kubectl.plugin.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,16 @@ if (( $+commands[kubectl] )); then
unset __KUBECTL_COMPLETION_FILE
fi

# Kube Context prompt
function kctx_prompt_info() {
[[ -z $(kccc) ]] && return
echo "${ZSH_THEME_KCTX_PREFIX:=<kctx:}$(kccc)${ZSH_THEME_KCTX_SUFFIX:=>}"
}

if [[ ! -v HIDE_KTCX_PROMPT ]]; then
RPROMPT='$(kctx_prompt_info)'"$RPROMPT"
fi

# This command is used a LOT both below and in daily life
alias k=kubectl

Expand Down