Created
August 14, 2019 14:52
-
-
Save teivah/7af135eca37e0865913d5a44abc980d1 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
NORMAL="\[\e[00m\]" | |
BLACK="\[\e[0;30m\]" | |
RED="\[\e[1;31m\]" | |
GREEN="\[\e[0;32m\]" | |
YELLOW="\[\e[0;33m\]" | |
BLUE="\[\e[0;34m\]" | |
PURPLE="\[\e[0;35m\]" | |
CYAN="\[\e[0;36m\]" | |
WHITE="\[\e[0;37m\]" | |
function prompt_cmd | |
{ | |
# Get current context | |
CONTEXT=$(cat ~/.kube/config | grep "current-context:" | sed "s/current-context: //") | |
if [ -n "$CONTEXT" ]; then | |
if [[ "$CONTEXT" == "prod-aws" ]]; then | |
export PS1="${BLUE}\W ${RED}\${CONTEXT}${NORMAL} \$ " | |
else | |
export PS1="${BLUE}\W ${YELLOW}\${CONTEXT}${NORMAL} \$ " | |
fi | |
fi | |
} | |
export PROMPT_COMMAND=prompt_cmd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment