Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@leshy
Created June 5, 2012 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leshy/2872327 to your computer and use it in GitHub Desktop.
Save leshy/2872327 to your computer and use it in GitHub Desktop.
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