Created
October 8, 2012 21:31
-
-
Save drock/3855121 to your computer and use it in GitHub Desktop.
Bash prompt to show current git status and 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
#Install git-core +bash_completion | |
#sudo port install git-core +bash_completion | |
#paste this into your .bash_profile | |
#customize the PS1 variable as desired | |
GIT_PS1_SHOWUPSTREAM="verbose" | |
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then | |
. /opt/local/etc/profile.d/bash_completion.sh | |
fi | |
source /opt/local/share/doc/git-core/contrib/completion/git-prompt.sh | |
function parse_git_dirty { | |
git diff --quiet HEAD &>/dev/null | |
[[ $? == 1 ]] && echo "⚡" | |
} | |
function parse_git_branch { | |
local branch=$(__git_ps1 "%s") | |
[[ $branch ]] && echo "[$branch$(parse_git_dirty)]" | |
} | |
export PS1="$GREEN\u@\h $RED\w $YELLOW\$(parse_git_branch)\[\033[00m\] \$" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment