Skip to content

Instantly share code, notes, and snippets.

@szymon-jez
Forked from justintv/.bashrc
Last active January 15, 2018 12:17
Show Gist options
  • Save szymon-jez/97de80ec98270ff405b5da4e2841df43 to your computer and use it in GitHub Desktop.
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
# 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