function show_git_branch {
echo -n `git branch --no-color 2> /dev/null | sed -e '/^[^*] /d' -e 's/* \(.*\)/\1/'`
}
function has_local_changes {
if ! git diff-files --quiet 2> /dev/null; then
echo -n '*'
fi
if ! git diff-index --cached --quiet HEAD 2> /dev/null; then
echo -n '!'
fi
}
function has_push {
HAS=`git rev-list -n 1 HEAD@{upstream}..HEAD 2> /dev/null`
if [ "$HAS" != "" ]; then
echo -n '->'
fi
}
function show_git_info {
if git rev-parse --git-dir > /dev/null 2>&1; then
echo -ne "\033[0;32m ("
show_git_branch
echo -ne "\033[1;37m"
has_local_changes
has_push
echo -ne "\033[0;32m)"
fi
}
function proml {
local LIGHT_BLUE="\[\033[0;94m\]"
local RED="\[\033[0;31m\]"
local RESET="\[\033[0;0m\]"
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}\
$LIGHT_BLUE\$(date +%H:%M:%S) \
$RED\u@\h:\w\$(show_git_info) \
$RESET\$ "
PS2='> '
PS4='+ '
}
proml
Original thanks to Chris Wanstrath.
Gitifying da prompt
Put in .bash_profile: