How to see color Ant output in MSYS/Git Bash?

前端 未结 2 516
甜味超标
甜味超标 2021-01-05 00:55

I\'d like to use AnsiColorLogger to get color ouput from Ant. I\'m using Git Bash on Windows.

I tried:

$ ant -logger org.apache.tools.ant.listener.A         


        
2条回答
  •  渐次进展
    2021-01-05 01:27

    After much Googling and experimentation, I combined several variations into a solution that works well for the particular combination of Git Bash, Ant and Windows.

    Relaunch Git Bash after adding the following lines to your .bashrc file:

    alias ant='cant'
    function cant {
      "ant" -logger org.apache.tools.ant.listener.AnsiColorLogger "$@" \
          2>&1 | perl -pe 's/(?<=\e\[)2;//g'
    }
    

    Git Bash Noob Tip: .bashrc file, if it exists, lives in your home directory. Here's how to create/edit it:

    $ cd
    $ notepad .bashrc &
    

提交回复
热议问题