彩色Git diff到HTML [英] Coloured Git diff to HTML
问题描述
我喜欢使用 git diff --color-words
清楚地看到文件中已更改的字词:
I enjoy using git diff --color-words
to clearly see the words that have changed in a file:
但我想分享与某人没有git或一个彩色终端为这个问题。因此,有没有人知道可以将颜色转义终端输出转换为HTML的工具或技巧?
However I want to share that diff with someone without git or a colour terminal for that matter. So does anyone know of a tool or trick that can convert colour escaped terminal output into HTML?
推荐答案
wget "http://www.pixelbeat.org/scripts/ansi2html.sh" -O /tmp/ansi2html.sh
chmod +x /tmp/ansi2html.sh
git diff --color-words --no-index orig.txt edited.txt | \
/tmp/ansi2html.sh > 2beshared.html
我真正需要的是一个 ANSI 转换为HTML转换器。我在 http://www.pixelbeat.org/ 找到了一个非常不错的。
What I really needed was an ANSI to HTML converter. And I found a very decent one on http://www.pixelbeat.org/.
注意:除非包括 - color
或 - color-words
NOTE: You might not see any coloration unless you include --color
or --color-words
, probably because piping causes git diff to exclude colors.
注意2:你可能需要安装gnu sed和awk,尤其是如果你'在Mac上。使用 brew install gnu-sed gawk
执行此操作。您可能需要手动将它们添加到您的路径,例如。与 ln -s /usr/local/Cellar/gnu-sed/4.2.2/bin/gsed / usr / local / bin /
。
NOTE 2: You may need to install gnu sed and awk, especially if you're on a Mac. Do so with brew install gnu-sed gawk
. You may need to add them to your path manually, too, e.g. with ln -s /usr/local/Cellar/gnu-sed/4.2.2/bin/gsed /usr/local/bin/
.
这篇关于彩色Git diff到HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!