Skip to content

Instantly share code, notes, and snippets.

@jamalnasir
Created October 1, 2017 08:14
Show Gist options
  • Save jamalnasir/72674b05717fd66726f73622b89e2621 to your computer and use it in GitHub Desktop.
Save jamalnasir/72674b05717fd66726f73622b89e2621 to your computer and use it in GitHub Desktop.
Add Git Branch Name to the Terminal Prompt
sudo nano ~/.bash_profile
# Git branch in prompt.
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\u@\h \W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
# If you are using an existing Terminal session, don’t forget to make the changes take effect by sourcing the file with the command
source ~/.bash_profile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment