[英]Is there a way to colorize the git add --interactive mode?
I am using git add --patch
a lot and I am looking for a way to have its output colorize (like in git diff --color
).我正在使用
git add --patch
很多,我正在寻找一种方法来使其 output 着色(如git diff --color
)。
Is there something out there or should I try and write a wrapper?那里有什么东西还是我应该尝试写一个包装器?
In your .gitconfig
:在您的
.gitconfig
:
[color]
interactive = true
I'm not sure exactly how this will get colorized, but that's the builtin option.我不确定这将如何着色,但这是内置选项。
The problem with adding 'ui = true' to the config file is that it impacts other commands.将“ui = true”添加到配置文件的问题在于它会影响其他命令。 For example, if you use 'git diff file.c > patch" to save patch files, the escape codes that make the color might end up in the output file.
例如,如果您使用“git diff file.c > patch”来保存补丁文件,则生成颜色的转义码可能会出现在 output 文件中。
Other options are to do it the command line:其他选项是在命令行中执行此操作:
git -c color.ui=true add -p foo.c
or, make an alias in the.git/config file:或者,在 .git/config 文件中创建一个别名:
[alias]
addp = -c color.ui=true add -p
addi = -c color.ui=true add -i
You could run it through Perl or somesuch and inject colour codes您可以通过 Perl 或类似的方式运行它并注入颜色代码
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.