Created
August 13, 2018 08:14
-
-
Save rcoup/e52968336b7ccade1bf031ffab36d847 to your computer and use it in GitHub Desktop.
bashrc for kubernetes context & namespace
This file contains hidden or 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_ps1() | |
{ | |
# Get current context | |
CONTEXT="$(kubectl config current-context)" | |
if [ -n "$CONTEXT" ]; then | |
NAMESPACE="$(kubectl config view -o=jsonpath="{.contexts[?(@.name==\"${CONTEXT}\")].context.namespace}")" | |
echo "⎈ $CONTEXT:${NAMESPACE:-default}" | |
fi | |
} | |
PS1='... \[\e[38;5;27m\]$(__kube_ps1) ...' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment