July 14, 2009

Show GIT branch on the Terminal

I ( like many people ) don't like the default themes on the MAC terminal and I don't have the time or skill to make a new shell code to make a nice colored theme.
Then I remembered that in some videos I've seen that the developers have a nice red and blue theme that also shows the GIT branch that you're in, which is pretty awesome.

I eventually found it here ( thank you to the developer for making it ) and the code is the following:

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\]"
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:\w$GREEN\$(parse_git_branch)$BLUE]\
$GREEN\$ "
PS2='> '
PS4='+ '
}
proml


You just have to edit .bash_profile in your home folder and paste that code in any part of the file ( don't delete the other text there!!!! ).

The theme is very nice and it even has a clock and a nice dollar sign for "waiting for command" ( did that make sense? ) and I said before I love the colors.
Hope you like it as well.