Skip to content

Instantly share code, notes, and snippets.

@celsobessa
Created November 29, 2019 02:57
Show Gist options
  • Select an option

  • Save celsobessa/25736f7a9ef94969a4e03c3873ee8a3e to your computer and use it in GitHub Desktop.

Select an option

Save celsobessa/25736f7a9ef94969a4e03c3873ee8a3e to your computer and use it in GitHub Desktop.
show git branch on your terminal prompt for unix like systems (unix, linux, macOs)
# Add this to ~/.bashrc
git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
export PS1="[\u@\h \W]\$(git_branch)\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment