问题
I want to use cdiff to colourize my diff output when using git. I could pass the output from git commands through cdiff, but I'd like to know if it's possible to not have to do this.
Specifically, when I use git log -p
, I want it to use cdiff to colourize the output, when I use git commit -p
, I want it to use cdiff to colourize the output. I'd like to tell git to not do the colouring itself, and to instead use this extra programme.
How do I do this?
回答1:
From what I can see, git produces its ANSI escape codes itself, without delegating to any third party tool: I don't see an easy way in git config to transfer that to an external program.
See for instance "contrib/completion/git-prompt.sh" (tested in t/t4026-color.sh).
Then Git calls the pager which you can configure as shown in "ANSI color in git is not displayed correctly".
来源:https://stackoverflow.com/questions/21144353/using-a-different-application-to-colourize-diff-output-in-git