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

前端 未结 2 495
甜味超标
甜味超标 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:18

    it's probably even easier to just set the environment variable ANT_ARGS. e.g. just put this in your .bashrc:

    export ANT_ARGS='-logger org.apache.tools.ant.listener.AnsiColorLogger'
    
    0 讨论(0)
  • 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 &
    
    0 讨论(0)
提交回复
热议问题