HOSTING : 10. Terminal tricks

Add colors to Git

With color it's better readable. Just execute this following commands :

git config --global color.ui true
git config --global color.diff true
git config --global color.status true

Display current working branch in Terminal

Always good to know in which branch you will add your changes...

Add following snippet in .bash_profile file. (vi ~/.bash_profile)

parse_git_branch() { 
	git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' 
} 
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "

You do not need to restart Terminal or anything for the changes to take effect, just do source ~/.bash_profile.

note: it works only if you don't use "export PS1" before in your file.