Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NORMAL="\[\033[0m\]"
RED="\[\033[0;31m\]"
GREEN="\[\033[01;32m\]"
BLUE="\[\033[01;34m\]"
YELLOW="\[\033[0;33m\]"
function parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
function kube_ps1() {
CONTEXT=$(cat ~/.kube/config | grep "server:" | awk -F: '{print $3}')
if [ -n "$CONTEXT" ]; then
echo "{K8S${CONTEXT}}"
fi
}
PS_LINE=`printf -- '- %.0s' {1..200}`
PS_K8S="$YELLOW\$(kube_ps1)"
PS_GIT="$NORMAL\$(parse_git_branch)"
PS_TIME="\[\033[\$((COLUMNS-10))G\] $RED[\t]"
export PS1="$GREEN\u@\h $PS_K8S $BLUE[:\w] ${PS_GIT} ${PS_TIME}\n${NORMAL}\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.