当我有一个差异时,我如何给它上色,使它看起来更好?
我想它的命令行,所以请没有GUI解决方案。
当我有一个差异时,我如何给它上色,使它看起来更好?
我想它的命令行,所以请没有GUI解决方案。
当前回答
使用bat命令:
diff file1 file2 | bat -l diff
其他回答
对我来说,我找到了一些解决方案:这是一个有效的解决方案
@echo off
Title a game for YouTube
explorer "https://thepythoncoding.blogspot.com/2020/11/how-to-echo-with-different-colors-in.html"
SETLOCAL EnableDelayedExpansion
for /F "tokens=1,2 delims=#" %%a in ('"prompt #$H#$E# & echo on & for %%b in (1) do rem"') do (
set "DEL=%%a"
)
echo say the name of the colors, don't read
call :ColorText 0a "blue"
call :ColorText 0C "green"
call :ColorText 0b "red"
echo(
call :ColorText 19 "yellow"
call :ColorText 2F "black"
call :ColorText 4e "white"
goto :Beginoffile
:ColorText
echo off
<nul set /p ".=%DEL%" > "%~2"
findstr /v /a:%1 /R "^$" "%~2" nul
del "%~2" > nul 2>&1
goto :eof
:Beginoffile
字符级色差: 安装ccdiff
ccdiff -r /usr/share/dict/words /tmp/new-dict
你可以改变Subversion配置使用colordiff:
~ / .subversion / config.diff
### Set diff-cmd to the absolute path of your 'diff' program.
### This will override the compile-time default, which is to use
### Subversion's internal diff implementation.
-# diff-cmd = diff_program (diff, gdiff, etc.)
+diff-cmd = colordiff
通过https://gist.github.com/westonruter/846524
diff的手册页没有建议从内部进行着色的解决方案。请考虑使用色差。它是diff的包装器,产生与diff相同的输出,除了它使用彩色语法高亮显示来增强输出以增加可读性:
diff old new | colordiff
或者是:
colordiff old new
安装:
Ubuntu/Debian: sudo apt-get install colordiff OS X: brew install colordiff或port install colordiff
使用Vim:
diff /path/to/a /path/to/b | vim -R -
或者更好的是,VimDiff(或vim -d,打字更短)将并排显示两个、三个或四个文件之间的差异。
例子:
vim -d /path/to/[ab]
vimdiff file1 file2 file3 file4