git_inspect_branch() {
git branch 2> /dev/null | grep ^* | sed 's/^\* \(.*\)$/:\1/g'
}
git_inspect_added() {
[[ $(git status 2> /dev/null | grep 'Untracked files:') != '' ]] && echo '+'
}
git_inspect_modified() {
[[ $(git status 2> /dev/null | grep 'modified:') != '' ]] && echo '*'
}
git_inspect_deleted() {
[[ $(git status 2> /dev/null | grep 'deleted:') != "" ]] && echo "-"
}
git_inspect_stash() {
[[ $(git stash list 2> /dev/null | grep 'stash@') != "" ]] && echo "?"
}
git_inspect_dirty() {
echo "$(git_inspect_added)$(git_inspect_modified)$(git_inspect_deleted)$(git_inspect_stash)"
}
NME="\u"
HST="\h"
DIR="\w"
PMT="\$"
RED="\[\033[31m\]"
GEN="\[\033[32m\]"
YEL="\[\033[33m\]"
OFF="\[\033[m\]"
MOD="\`if [ \$? = 0 ]; then echo 😃; else echo 😓; fi\`" # Mountain Lion only
# MOD="\`if [ \$? = 0 ]; then echo ':)'; else echo ':('; fi\`" # Other OSs
GIT="\`git_inspect_branch\`"
DIF="\`git_inspect_dirty\`"
PMT="\`if [ "$(id -u)" = "0" ]; then echo '#'; else echo '>'; fi\`"
PS1="$MOD $NME@$RED$HST$OFF:$DIR$GEN$GIT$OFF$RED$DIF$OFF$PMT "