Created
June 5, 2018 04:44
-
-
Save bfleming-ciena/337fb43582cc02694ab1ff7e5db42689 to your computer and use it in GitHub Desktop.
kubernetes cluster and namespace bash prompt (tested with os-x)
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
# Sorry for not mentioning the credit to the original author. I lost the original link. I just added the namespace to the picture. | |
function kube_context() { | |
# could have used $?, but it was easier with a string compare | |
local ctx=$(kubectl config current-context 2>&1) | |
local ns=$(kubectl config get-contexts --no-headers | grep '*' | awk '{print $5}') | |
if [ "${ctx}" != "error: current-context is not set" ]; then | |
echo -n "<${ctx}:$ns> " | |
fi | |
} | |
Blue='\e[0;34m' # Blue | |
White='\e[0;37m' # White | |
BRed='\e[1;31m' # Red | |
IWhite='\e[0;97m' # White | |
LightBlue='\e[1;34m' | |
PS1="\[$Blue\]\t\[$BWhite\]\[$LightBlue\] \$(kube_context)\[$BRed\]\[$BRed\]\w\[\033[m\]\[$IWhite\]\$(__git_ps1)\[$White\]\$ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment