I recently saw that the git console in Windows is colored, e.g. Green for additions, red for deletions, etc. How do I color my git console like tha
Well, if you are not satisfied with the default setting, you can use ANSI escape code to help you set the color, and if you want to modify some text, you can write bash to help you. see as below:
# .gitconfig
[alias]
st-color = "!f() { \
echo -n -e '\\033[38;2;255;0;01m\\033[4m' ;\
git status -s | grep ' D' | \
sed -e 's/^ ./DELETE:/' ; \
echo -n -e '\\033[m' ;\
\
echo -n -e '\\033[48;2;128;128;128m' ;\
echo -n -e '\\033[38;2;0;255;01m' ;\
git status -s | grep ' [AM]' | \
sed -e 's/^ ./NEW OR MODIFY:/' ; \
echo -n -e '\\033[m' ;\
\
echo -n -e '\\033[38;2;255;0;255m' ;\
echo Rename ;\
git status -s | grep 'R ' | \
sed -e 's/^..//' ; \
echo -n -e '\\033[m' ;\
}; f"
you can write the long script on .gitconfig use the syntax as below:
[alias]
your-cmd = !f() { \
\
}; f"
echo -n -e (see more echo)
\\033[38;2;255;0;0m\\033[4m (see more SGR parameters)
\\033[38;2;255;0;0m : 38 mean fore color. 255;0;0 = Red | r;g;b\\033[4m : underlinegrep : The grep command is used to search text.
sed -e 's/be_replace_string/new_string/' replace string to new string.