Skip to content

Instantly share code, notes, and snippets.

@leshy
Created Jun 5, 2012
Embed
What would you like to do?
fancy git bash prompt
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'
}
function git_repo_name {
basename $(git rev-parse --show-toplevel)
}
function git_status {
REPO=$(git_repo_name)
WD=${PWD/$HOME/\~}
if [ "$REPO" != "/" ]; then
WD=${PWD/$REPO/\\033[00;35m$REPO\\033[00;33m}
echo -en "\033[00;33m$WD \033[00;35m[\033[00;32m$(parse_git_branch)\033[00;35m]"
else
echo -en "\033[00;33m$WD"
fi
}
function usercolor {
echo -en $USERCOLOR
}
PS1='\[\033[00;36m\]\D{%d:%k:%M:%S} \[\033[00;32m\]$(usercolor)\u\[\033[00;32m\]@\h $(git_status) \[\033[00;33m\]\$ \[\033[00m\]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment