Skip to content

Instantly share code, notes, and snippets.

@RyEnd
Created July 30, 2016 14:50
Show Gist options
  • Save RyEnd/4c3b9049b050dc5847af98448f0f83d9 to your computer and use it in GitHub Desktop.
Save RyEnd/4c3b9049b050dc5847af98448f0f83d9 to your computer and use it in GitHub Desktop.
git branch in bash prompt
# ...
# ...
# ...
# git branch in prompt
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
export PS1="\[\e[0;33m\]\u\[\e[0m\]: \[\e[0;34m\]\W\[\033[32m\]\$(parse_git_branch)\[\033[00m\] $ "
@RyEnd
Copy link
Author

RyEnd commented Sep 8, 2016

before: john@john:~/Documents/yourRepo/ $
after: john: yourRepo (master) $

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment