Customized Git Prompt

Find your way to the Linux operating system

This small script will adjust your PS1 when cd’ing into your git directories.

Just source it from .bashrc or .profile, colors can be adjusted easily.


# bash function returning the git branch as a label
parse_git_branch() {
    git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'

# Where you can change the prompt colors
export PS1="\u@\h \[\033[32m\]\w\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ "

Thanks to:
Paul von Spreckelsen