Created
November 21, 2012 02:47
-
-
Save mttrb/4122721 to your computer and use it in GitHub Desktop.
Bash Prompt - Success/Fail and Git Branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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