Skip to content

Instantly share code, notes, and snippets.

@acidDrain
Last active November 11, 2018 13:08
Show Gist options
  • Save acidDrain/9cdec769ce9f4a20ffd475dcbfc54ef7 to your computer and use it in GitHub Desktop.
Save acidDrain/9cdec769ce9f4a20ffd475dcbfc54ef7 to your computer and use it in GitHub Desktop.
Bash prompt that includes current Kubernetes context and current git branch
parse_git_branch() {
git branch 2> /dev/null | grep "^\*" | sed -e 's/\(\* \)\(.*\)/\(\2\)/g'
}
export PS1="\[\e[97m\][\$(kubectl config current-context 2> /dev/null )]\[\e[39m\] \$USER@\$HOSTNAME:\[\e[38;5;226m\]\w\[\e[39m\]\[\e[96m\] \$(parse_git_branch)\[\e[0m\]$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment