Skip to content

Instantly share code, notes, and snippets.

@chazmaniandinkle
Last active August 16, 2018 14:23
Show Gist options
  • Save chazmaniandinkle/4299fc6d4fa44d8ee1614d21e5582239 to your computer and use it in GitHub Desktop.
Save chazmaniandinkle/4299fc6d4fa44d8ee1614d21e5582239 to your computer and use it in GitHub Desktop.
Small script to allow for toggling the kubecontext element in the POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS variable.
# Version: 1.0
# Date: 8/16/2018
# Author: Chaz Dinkle
# Powerlevel9k kubectl toggle
kon () {
RPROMPT=($POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS)
if [[ ${RPROMPT[(ie)kubecontext]} -gt ${#RPROMPT} ]]
then
RPROMPT[1]=(kubecontext $RPROMPT)
else
echo "kubecontext already enabled."
fi
}
koff () {
RPROMPT=($POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS)
if [[ ${RPROMPT[(ie)kubecontext]} -lt ${#RPROMPT} ]]
then
RPROMPT[${RPROMPT[(ie)kubecontext]}]=()
else
echo "kubecontext already disabled."
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment