linux亮色_Shell 终端文件对比高亮显示

日常开发当中,团队协作就要涉及到代码版本的管理,代码版本不断的变化,项目合并时通常会比较同一代码不同版本之间具体发生了哪些变化?还有常在shell终端开发下的我们对比文件我们又通常会用到一些对比的命令,无论是Linux的对比命令还是代码版本管理的对比,输出的对比文本大都比较朴素,如果差异小还好,如果差异大简直要崩溃,刚好看到一个小工具,也从网上查了些相关资料,觉的是一个实用的小工具,在此分享给大家。

ColorDiff 介绍

ColorDiff 安装

ColorDiff 不同场景下运用

ColorDiff 介绍

colordiff 是perl 开发一款小工具,与diff 功能一样,但其拥有漂亮的语法和高亮差异显示。小巧轻便又可以定制颜色方案。colordiff 适用于 Linux 及 BSD 系统,目前已被包含到 Debian、Ubuntu、Gentoo、Arch Linux、Fedora、FreeBSD 等发行版中。—— 【官方网站】

ColorDiff 安装

以下简单针对几个系统做下介绍:

Mac 系统

安装方式

brew install colordiff

Ubuntu

apt-get install colordiff

yum install colordiff

或者手动安装,因软件本身很小巧,安装也很简单,将下载到的源码包解压后,直接进行目录中执行”make install”即可,程序和配置文件分别默认安装在/usr/local/bin和/etc目录下

wget http://www.colordiff.org/colordiff-1.0.16.tar.gz

tar -zxvf colordiff-1.0.16.tar.gz

cd colordiff-1.0.16

make install

ColorDiff 不同场景下的运用

文件对比

对比linux 下两文件内容的差异:

colordiff file1 file2

配合diff 命令

ColorDiff用于diff命令的管道输出:

diff -u file1 file2 | colordiff

配合svn diff

在 ~/.subversion/config 內修改:

[helpers]

diff-cmd = colordiff

如果需要修改颜色:sudo vim /usr/local/etc/colordiffrc

[helpers]

49 ### Set editor-cmd to the command used to invoke your text editor.

50 ### This will override the environment variables that Subversion

51 ### examines by default to find this information ($EDITOR,

52 ### et al).

53 # editor-cmd = editor (vi, emacs, notepad, etc.)

54 ### Set diff-cmd to the absolute path of your 'diff' program.

55 ### This will override the compile-time default, which is to use

56 ### Subversion's internal diff implementation.

57 # diff-cmd = diff_program (diff, gdiff, etc.)

58 ### Set diff3-cmd to the absolute path of your 'diff3' program.

59 ### This will override the compile-time default, which is to use

60 ### Subversion's internal diff3 implementation.

61 # diff3-cmd = diff3_program (diff3, gdiff3, etc.)

62 ### Set diff3-has-program-arg to 'yes' if your 'diff3' program

63 ### accepts the '--diff-program' option.

64 # diff3-has-program-arg = [yes | no]

65 ### Set merge-tool-cmd to the command used to invoke your external

66 ### merging tool of choice. Subversion will pass 4 arguments to

67 ### the specified command: base theirs mine merged

68 # merge-tool-cmd = merge_command

69 diff-cmd = colordiff

70 ### Section for configuring tunnel agents.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值