Created
October 1, 2017 08:14
-
-
Save jamalnasir/72674b05717fd66726f73622b89e2621 to your computer and use it in GitHub Desktop.
Add Git Branch Name to the Terminal Prompt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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