Git PS1 Prompt

How to start with Linux

Git PS1 Prompt

Customize your (GIT) PS1 prompt to show you when you are working inside GIT repository directories. You can copy below script and add it to  you ~/.bashrc file

Re-open your terminal or: $ source ~/.bashrc to load your new ~/.bashrc

Only interested in a custom PS1 prompt, look here: Custom PS1 Prompt

# 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\] $ "

# Or if you like more colors (Dark terminal background)
export PS1="\[\033[1;34m\][\[$(tput bold)\033[1;37m\]\u\[\033[01;34m\]@\[\033[01;37m\]\h\[\033[00m\]:\[\033[38;5;39m\]\w\[\033[1;34m\]]\[\033[1;33m\]\$(parse_git_branch)\[\033[1;37m\]\$\[\033[00m\] "

Thanks to: Paul von Spreckelsen