Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to colorize git push output

Tags:

git

bash

git-bash

it's possible to create an git alias to colorize the output, in error case, of git push command?

I have one that works to log, but i can't modify it to works with push.

git log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%C(62)\\ [%cn]\\ %ce" --decorate

example of error message:

"error: failed to push some refs to 'https://github.com/user/projectname.git'"

like image 912
L.Barral Avatar asked Oct 23 '25 17:10

L.Barral


1 Answers

What should the push print?

push printout the result of the "pushed" code to the server. You can have server side hook which sends out colored messages to the user.

pre-receive hook

#!/bin/sh

# Output colors
red='\033[0;31m';
green='\033[0;32m';
yellow='\033[0;33m';
default='\033[0;m';

# personal touch :-)
echo "${red}"
echo "                                         "
echo "                   |ZZzzz                "
echo "                   |                     "
echo "                   |                     "
echo "      |ZZzzz      /^\            |ZZzzz  "
echo "      |          |~~~|           |       "
echo "      |        |-     -|        / \      "
echo "     /^\       |[]+    |       |^^^|     "
echo "  |^^^^^^^|    |    +[]|       |   |     "
echo "  |    +[]|/\/\/\/\^/\/\/\/\/|^^^^^^^|   "
echo "  |+[]+   |~~~~~~~~~~~~~~~~~~|    +[]|   "
echo "  |       |  []   /^\   []   |+[]+   |   "
echo "  |   +[]+|  []  || ||  []   |   +[]+|   "
echo "  |[]+    |      || ||       |[]+    |   "
echo "  |_______|------------------|_______|   "
echo "                                         "
echo "                                         "
echo "      ${green}You have just committed code ${red}  " 
echo "      Your code ${yellow}is bad.!!!      "
echo "      ${red} Do not ever commit again    "
echo "                                         "
echo "${default}"

like image 78
CodeWizard Avatar answered Oct 26 '25 06:10

CodeWizard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!