Created
January 21, 2014 15:40
-
-
Save sevenmaxis/8542402 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
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | |
c_reset=`tput sgr0` | |
c_user=`tput setaf 2; tput bold` | |
c_path=`tput setaf 4; tput bold` | |
c_git_clean=`tput setaf 2` | |
c_git_dirty=`tput setaf 1` | |
else | |
c_reset= | |
c_user= | |
c_path= | |
c_git_cleanclean= | |
c_git_dirty= | |
fi | |
git_prompt () | |
{ | |
if ! git rev-parse --git-dir > /dev/null 2>&1; then | |
return 0 | |
fi | |
git_branch=$(git branch 2>/dev/null| sed -n '/^\*/s/^\* //p') | |
if git diff --quiet 2>/dev/null >&2; then | |
git_color="${c_git_clean}" | |
else | |
git_color=${c_git_cleanit_dirty} | |
fi | |
echo " [$git_color$git_branch${c_reset}]" | |
} | |
PS1='${c_user}\u${c_reset}@${c_user}\h${c_reset}:${c_path}\w${c_reset}$(git_prompt)\$ ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment