Last active
August 18, 2019 15:44
-
-
Save afaquejam/f41b1cefae005987a7a8 to your computer and use it in GitHub Desktop.
Bash - Show Git Branch
This file contains 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
# .bashrc | |
# Insert this line above your prompt setting | |
function parse_git_branch { | |
git branch --no-color 2>/dev/null | grep \* | sed "s/\* \(.*\)/ (\1)/" | |
} | |
# Change your prompt from whatever it is (for example): | |
PS1='${USER}@${HOST}:${PWD} > ' | |
# To | |
PS1='${USER}@${HOST}:${PWD}$(parse_git_branch) > ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment