Coloured Git diff to HTML

前端 未结 7 592
盖世英雄少女心
盖世英雄少女心 2020-11-28 19:19

I enjoy using git diff --color-words to clearly see the words that have changed in a file:

\"Screen

7条回答
  •  眼角桃花
    2020-11-28 19:34

    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
    

    What I really needed was an ANSI to HTML converter. And I found a very decent one on http://www.pixelbeat.org/.

    NOTE: You might not see any coloration unless you include --color or --color-words, probably because piping causes git diff to exclude colors.

    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/.

提交回复
热议问题