I have a bash PS1 to get a red color if my git dir is changed or green if not is changed.
if [ $? -eq 0 ]; then \
echo "$(echo `git status` | grep "nothing to commit" > /dev/null 2>&1; \
if [ "$?" -eq "0" ]; then \
# @4 - Clean repository - nothing to commit
echo "\n'$Green'"$(__git_ps1 "(%s)"'$Color_Off'); \
else \
# @5 - Changes to working tree
echo "\n'$IRed'"$(__git_ps1 "(%s)"'$Color_Off'); \
fi)\$ "; \
fi)'
This works fine! But the problem is that in some work dir is very slow because exists many changes and a big diff.
What is the better way to get git status boolean (yes changed or no changed) without a full
I tried with git status --short
or git status --porcelain
but is very slow yet.