Create a gist now

Instantly share code, notes, and snippets.

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\$ "
}
prompt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment