Created
August 18, 2011 14:50
-
-
Save shreyansb/1154210 to your computer and use it in GitHub Desktop.
git branch and cleanliness status in the bash prompt
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
parse_git_dirty() { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e "/^[^*]/d" -e "s/* \(.*\)/(\1$(parse_git_dirty))/" | |
} | |
PROMPT_COMMAND='CurDir=`pwd|sed -e "s!$HOME!~!"|sed -E "s!([^/])[^/]+/!\1/!g"`' | |
PS1='[\u@\h $CurDir $(parse_git_branch)]\$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment