How to have a nice bash shell prompt that will print the current git branch on the prompt.

This interesting bash function will get the git branch of the current working directory and then print it in the shell prompt. This could be very useful for a programmer. git_branch() { git branch 2> /dev/null | sed -e ‘/^[^*]/d’ -e ‘s/* \(.*\)/(\1)/’ }   PS1=’┌──[\u@\h]─[\w]\n└──╼ $(git_branch) ╼ \$ ‘git_branch() { git branch 2> /dev/null … Read more