Skip to content

Instantly share code, notes, and snippets.

@mttrb
Created November 21, 2012 02:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mttrb/4122721 to your computer and use it in GitHub Desktop.
Save mttrb/4122721 to your computer and use it in GitHub Desktop.
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