Created
June 2, 2011 20:57
-
-
Save granth/1005312 to your computer and use it in GitHub Desktop.
git 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
export PS1='\[\033]0;\w\007\[\033[0;32m\]\W\[\033[0;38m\] $(git_branch)$(prompt_status "%s") ' | |
prompt_status() { | |
local branch=$(__git_ps1 "%s") | |
if [ -n "$branch" ]; then | |
if git_dirty; then | |
echo "⚡" | |
return | |
fi | |
fi | |
echo "→" | |
} | |
git_branch() { | |
local branch=$(__git_ps1 "%s") | |
if [ -n "$branch" ]; then | |
if [[ ! $(git config homedir.repo) ]]; then | |
echo -n "$branch" | |
fi | |
fi | |
} | |
git_dirty() { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment