Skip to content

Instantly share code, notes, and snippets.

Created November 21, 2012 02:47
What would you like to do?
Bash Prompt - Success/Fail and Git Branch
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \[\1\]/'
function prompt {
local DEFAULT="\[\033[0m\]"
local RED="\[\033[0;31m\]"
local GREEN="\[\033[0;32m\]"
local BLUE="\[\033[0;34m\]"
PS1="\`if [ \$? == '0' ]; then echo '$GREEN'; else echo '$RED'; fi\`\h:\W \u$BLUE\$(parse_git_branch)$DEFAULT\$ "
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment