If you work mostly in the Linux terminal and use Git, you know how useful it is to have the Git branch name displayed in your bash prompt.
By default, the bash prompt looks like this:
To include the Git branch name in your bash prompt, you need to edit the .bashrc file in your user home directory and add these lines:
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W \[\033[01;33m\]\$(git_branch)\[\033[00m\]\$ "
After applying these changes, your bash prompt will display the Git branch name like this: