-
-
Save vitebo/7e5e02b78c0416720c74935fedd4f930 to your computer and use it in GitHub Desktop.
show kubectl context on bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# .bash_profile | |
NORMAL="\[\033[00m\]" | |
BLUE="\[\033[01;34m\]" | |
YELLOW="\[\e[1;33m\]" | |
GREEN="\[\e[1;32m\]" | |
source $HOME/kube-prompt.sh | |
export PS1="${BLUE}\W ${GREEN}\u${YELLOW}\$(__kube_ps1)${NORMAL} \$ " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# kube-prompt.sh | |
#!/bin/bash | |
__kube_ps1() | |
{ | |
# Get current context | |
CONTEXT=$(cat ~/.kube/config | grep "current-context:" | sed "s/current-context: //") | |
if [ -n "$CONTEXT" ]; then | |
echo "(k8s: ${CONTEXT})" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment