-
-
Save szymon-jez/97de80ec98270ff405b5da4e2841df43 to your computer and use it in GitHub Desktop.
Display git branch in bash prompt and start prompt in new line
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
# If you work with git, you've probably had that nagging sensation of not knowing what branch you are on. Worry no longer! | |
parse_git_branch() { | |
git branch 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
export PS1='\[\033[01;32m\][\u@\h\[\033[01;37m\] \W\[\033[01;32m\]]$(parse_git_branch)\n\$\[\033[00m\] ' | |
# This will change your prompt to display not only your working directory but also your current git branch, if you have one. Pretty nifty! | |
# This will also make the command line be in two lines. | |
# [szymon@kolec4 tmp] | |
# $ cd projects/demo/ | |
# [szymon@kolec4 demo] (master) | |
# $ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment