adds git branch and commit info to your prompt - place at the top of your .bash_profile
#http://www.simplitex.com/2008/07/21/the-tools-we-git-adding-git-branch-and-commit-info-to-your-prompt/
# Determine the current branch and outputs it or "detached"
function parse_git_branch {
local BOLD_CYAN="\033[1;36m"
local BRANCH=`git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'`
if [ "$BRANCH" = "((no branch))" ]
then
# Use " \b" - space backspace, because it won't work w/o space between ansi chars and text
echo -e "($BOLD_CYAN \bdetached)"
else
echo $BRANCH
fi
}
# Either output the current commit's nearest tag, or if not an abbreviated hash
function describe_git_commit {
local PURPLE="\033[0;35m"
local YELLOW="\033[0;33m"
local CYAN="\033[0;36m"
local COMMIT="`git describe --always 2> /dev/null`"
if [ $COMMIT ]
then
echo -e "\b$PURPLE:$YELLOW$COMMIT$CYAN)"
fi
}
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local GREEN="\[\033[0;32m\]"
local LIGHT_GREEN="\[\033[1;32m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
local CYAN="\[\033[0;36m\]"
local PURPLE="\[\033[0;35m\]"
local YELLOW="\[\033[0;33m\]"
local DEFAULT="\[\033[0;00m\]"
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}\
$BLUE[$RED\$(date +%H:%M)$BLUE]\
$BLUE[$RED\u@\h:$LIGHT_GRAY\w\
$CYAN\$(parse_git_branch)\$(describe_git_commit)$BLUE]\
$GREEN\$$GREEN"
PS2='> '
PS4='+ '
}
proml