Skip to content

Instantly share code, notes, and snippets.

@bhavanki
Last active December 21, 2015 23:29
Show Gist options
  • Save bhavanki/6382306 to your computer and use it in GitHub Desktop.
Save bhavanki/6382306 to your computer and use it in GitHub Desktop.
.bashrc snippet to include the current Git branch in the prompt
parse_git_branch() {
git branch --no-color 2>/dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \1 /'
}
gitps1() {
local GREEN="\[\033[0;32m\]"
local DEFAULT="\[\033[0m\]"
PS1="[\u@\h \W]$GREEN\$(parse_git_branch)$DEFAULT\$ "
}
gitps1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment