I wanted to provide a slightly more updated method for doing this for the simple reason that when I tried the primary answer it was unbearably slow, nearly a second between outputted lines. That might be due to running git for windows as opposed to on a *nix machine, but the 'grep' command takes too long to be valid. That being said, the same effect can be achieved given the output of the "--name-status" parameter for both git log and git diff are simple strings, and so using simple string matching instead of the 'grep' tool, my output was almost immediate.
for i in "$@"
do
if [[ ${i:0:1} == "M" ]] #grep -q "^M" <<< "$i"
then echo -e "\e[34m $i \e[0m"
elif [[ ${i:0:1} == "D" ]] #grep -q "^D" <<< "$i"
then echo -e "\e[31m $i \e[0m"
elif [[ ${i:0:1} == "A" ]] #grep -q "^A" <<< "$i"
then echo -e "\e[32m $i \e[0m"
else echo -e "$i"
fi
done
I also added the code for "added" as well as a default so if there is other text (like git log --pretty) it will not be ignored.
Jaeden "Sifo Dyas" al'Raec Ruiner
PS - use the same xargs command with the delimiter but the above script is faster at parsing than grep (on a windows box)
git status -s
? – 7ochem Dec 12 '16 at 08:16