How do I prettily print out a git-diff output?

后端 未结 3 710
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-18 19:52

for my upcoming Bachelor thesis, I am required to print out the git-diff output for the appendix of the paper. I really like the output of git diff --color-words, b

相关标签:
3条回答
  • 2021-02-18 20:17

    I just tried an npm package hosted on Github: pretty-diff

    You install it via npm and run it as you would with git-diff, for example:

    pretty-diff HEAD^
    

    A new browser window opens and you can save it as html. I've tried to open it again in a different browser and colors are still showing. You can also use your github account to create gists and share them.

    0 讨论(0)
  • 2021-02-18 20:23

    Since you are using a Mac with the terminal application, it is as simple as cut and pasting from the terminal to another application.

    0 讨论(0)
  • 2021-02-18 20:24

    Use aha. You can install it in ubuntu with sudo apt-get install aha. Also see https://github.com/theZiz/aha.

    $ git diff --color-words | aha > index.html
    $ firefox index.html
    

    Firefox should then be able to print it in color. Check out aha --help for some other cool options.

    0 讨论(0)
提交回复
热议问题