Last active
January 2, 2020 22:14
-
-
Save viniciusjssouza/df2669da5b47a54ccf4895f61db289ee 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
# 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 | |
} | |
# .bash_profile | |
NORMAL="\[\033[00m\]" | |
BLUE="\[\033[01;34m\]" | |
YELLOW="\[\e[1;33m\]" | |
GREEN="\[\e[1;32m\]" | |
source ~/kube-prompt.sh | |
export PS1="${BLUE}\W ${GREEN}\u${YELLOW}\$(__kube_ps1)${NORMAL} \$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment