Created
January 24, 2014 17:48
-
-
Save mislav/8602351 to your computer and use it in GitHub Desktop.
Simple bash prompt that shows current git branch (if any) and colors the dollar sign in red if the last command exited with a nonzero status.
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
_git_prompt() { | |
local ref="$(command git symbolic-ref -q HEAD 2>/dev/null)" | |
if [ -n "$ref" ]; then | |
echo " (${ref#refs/heads/})" | |
fi | |
} | |
_failed_status() { | |
[ "$PIPESTATUS" -ne 0 ] && printf "$" | |
} | |
_success_status() { | |
[ "$PIPESTATUS" -eq 0 ] && printf "$" | |
} | |
PS1='\[\e[0;31m\]\w\[\e[m\]$(_git_prompt) \[\e[1;31m\]$(_failed_status)\[\e[m\]$(_success_status) ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment