在每个更改的行中突出显示更改的行和更改的字节 [英] Highlight changed lines and changed bytes in each changed line

查看:15
本文介绍了在每个更改的行中突出显示更改的行和更改的字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开源项目 Trac 有一个出色的差异荧光笔 —它突出显示更改的行以及每个更改行中更改的字节!请参阅此处此处查看示例.

Open Source project Trac has an excellent diff highlighter — it highlights changed lines and changed bytes in each changed line! See here or here for examples.

有没有办法在 bash 终端、gitvim 中使用相同颜色的突出显示(即更改行和更改字节)用于差异输出(补丁文件)?

Is there way to use the same color highlight (i.e. changed lines and changed bytes too) in bash terminal, git, or vim for diff output (patch-file)?

推荐答案

diff-highlight Perl contrib 脚本 生成的输出与 Trac 屏幕截图的输出非常相似,以至于 Trac 很可能正在使用它:

The diff-highlight Perl contrib script produces output so similar to that of the Trac screenshots that it is likely that Trac is using it:

安装:

wget https://raw.githubusercontent.com/git/git/fd99e2bda0ca6a361ef03c04d6d7fdc7a9c40b78/contrib/diff-highlight/diff-highlight && chmod +x diff-highlight

将文件 diff-highlight 移动到 ~/bin/ 目录(或您的 $PATH 所在的任何位置),然后添加跟随你的 ~/.gitconfig:

Move the file diff-highlight to the ~/bin/ directory (or wherever your $PATH is), and then add the following to your ~/.gitconfig:

[pager]
        diff = diff-highlight | less
        log = diff-highlight | less
        show = diff-highlight | less

@cirosantilli 建议的单复制粘贴安装:

Single copy paste install suggested by @cirosantilli:

cd ~/bin
curl -O https://raw.githubusercontent.com/git/git/fd99e2bda0ca6a361ef03c04d6d7fdc7a9c40b78/contrib/diff-highlight/diff-highlight
chmod +x diff-highlight
git config --global pager.log 'diff-highlight | less'
git config --global pager.show 'diff-highlight | less'
git config --global pager.diff 'diff-highlight | less'
git config --global interactive.diffFilter diff-highlight

这篇关于在每个更改的行中突出显示更改的行和更改的字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆