Last active
October 31, 2017 11:04
-
-
Save khash/441a055f3376bb0b64134f614546f749 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
__parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/[\1]/' | |
} | |
__kube_ps1() | |
{ | |
# Get current context | |
CONTEXT=$(cat ~/.kube/config | grep "current-context:" --color=NO | sed "s/current-context: //") | |
if [ -n "$CONTEXT" ]; then | |
if [ "$CONTEXT" = "production" ]; then | |
echo -e "${BRIGHT}${WHITE}${RED_BG}${BLINK}${CONTEXT}${NORMAL}" | |
else | |
echo -e "${YELLOW}${CONTEXT}${NORMAL}" | |
fi | |
fi | |
} | |
__gcloud_ps1() | |
{ | |
CONTEXT=$(cat ~/.config/gcloud/active_config) | |
if [ -n "$CONTEXT" ]; then | |
if [ "$CONTEXT" = "production" ]; then | |
echo -e "${BRIGHT}${WHITE}${RED_BG}${BLINK}${CONTEXT}${NORMAL}" | |
else | |
echo -e "${YELLOW}${CONTEXT}${NORMAL}" | |
fi | |
fi | |
} |
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
BLACK=$(tput setaf 0) | |
BLACK_BG=$(tput setab 0) | |
RED=$(tput setaf 1) | |
RED_BG=$(tput setab 1) | |
GREEN=$(tput setaf 2) | |
GREEN_BG=$(tput setab 2) | |
LIME_YELLOW=$(tput setaf 190) | |
LIME_YELLOW_BG=$(tput setab 190) | |
YELLOW=$(tput setaf 3) | |
YELLOW_BG=$(tput setab 3) | |
POWDER_BLUE=$(tput setaf 153) | |
POWDER_BLUE_BG=$(tput setab 153) | |
BLUE=$(tput setaf 4) | |
BLUE_BG=$(tput setab 4) | |
MAGENTA=$(tput setaf 5) | |
MAGENTA_BG=$(tput setab 5) | |
CYAN=$(tput setaf 6) | |
CYAN_BG=$(tput setab 6) | |
WHITE=$(tput setaf 7) | |
WHITE_BG=$(tput setab 7) | |
BRIGHT=$(tput bold) | |
NORMAL=$(tput sgr0) | |
BLINK=$(tput blink) | |
REVERSE=$(tput smso) | |
UNDERLINE=$(tput smul) | |
source ~/.kube-prompt.sh | |
export PS1="\[${CYAN}\]k:\[${NORMAL}\] \$(__kube_ps1)\[${GREEN}\]/\[${CYAN}\]g:\[${NORMAL}\]\$(__gcloud_ps1)\[${NORMAL}\] \n\[${GREEN}\]\u\[${NORMAL}\]@\[${GREEN}\]\h \[${MAGENTA}\]\$(__parse_git_branch) \[${POWDER_BLUE}\]\w \[${NORMAL}\]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment