Created
February 27, 2010 19:01
-
-
Save bradleybuda/316884 to your computer and use it in GitHub Desktop.
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
source /usr/local/share/doc/git-core/contrib/completion/git-completion.bash | |
# git status with a dirty flag | |
function __git_status_flag { | |
git_status="$(git status 2> /dev/null)" | |
remote_pattern="^# Your branch is (.*) of" | |
diverge_pattern="# Your branch and (.*) have diverged" | |
if [[ ! ${git_status}} =~ "working directory clean" ]]; then | |
state="⚡" | |
spacer=" " | |
fi | |
if [[ ${git_status} =~ ${remote_pattern} ]]; then | |
spacer=" " | |
if [[ ${BASH_REMATCH[1]} == "ahead" ]]; then | |
remote="↑" | |
else | |
remote="↓" | |
fi | |
fi | |
if [[ ${git_status} =~ ${diverge_pattern} ]]; then | |
remote="↕" | |
spacer=" " | |
fi | |
echo "${state}${remote}${spacer}" | |
} | |
PS1='\[\e[32m\]\u@\[\e[1m\]\h\[\e[22m\]:\[\e[1;34m\]\w\[\e[22;35m\]$(__git_ps1 " [\[\e[33m\]$(__git_status_flag)\[\e[35m\]%s]")\[\e[33m\] \$ \[\e[0m\]' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment