Nov 222013
Here is my custom PS1 for GIT.
You can see if you are in a GIT tree, the current branch and the status of the branch (the + or the – before the branch)
The special command to obtain this kind of prompt is
Download : myps1.sh
git_or_not() { git rev-parse --is-inside-work-tree &> /dev/null ; } git_status() { [ -n "$(git status --short 2> /dev/null)" ] && echo -n "+ " || echo -n "- " ; } git_branch() { echo "$(git branch 2> /dev/null |grep -e ^* |sed 's/\* //' )" ; } export -f git_or_not git_status git_branch # Terminal needs to be UTF-8 PS1="\n\[\033[1;37m\]\342\224\214($( if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;34m\]\u@\h'; fi )\[\033[1;37m\])\342\224\200(\$( if [[ \$? == 0 ]]; then echo \"\[\033[01;32m\]\342\234\223\"; else echo \"\[\033[01;31m\]\342\234\227\"; fi )\[\033[1;37m\])\342\224\200(\[\033[1;34m\]\@\d\[\033[1;37m\])\[\033[1;37m\]\$( if git_or_not ; then echo \342\224\200\(\[\033[0\;31m\]\$(git_status)\$(git_branch)\[\033[1\;37m\]\) else echo \342\224\200\(\[\033[0\;34m\]not a Git repository\[\033[1\;37m\]\) fi )\n\342\224\224\342\224\200(\[\033[1;32m\]\w\[\033[1;37m\])\342\224\200(\[\033[1;32m\]\$( ls -1 | wc -l | sed 's: ::g' ) files, \$( ls -lah | grep -m 1 total | sed 's/total //' )b\[\033[1;37m\])\342\224\200> \[\033[0m\]"
Insert it in your .bash_profile or /etc/bash.bashrc