我在我的~/.hgrc
中使用extdiff。
[extensions]
pager =
hgext.extdiff =
[extdiff]
# add new command that runs GNU diff(1) in 'side-by-side' mode
cmd.sdiff = sh
opts.sdiff = -c 'diff -dbB --left-column -y -W `tput cols` $0 $1'
[pager]
pager = LESS='FRX' less
attend = cat, diff, sdiff, glog, log, incoming, outgoing, lg, show, lga
这意味着我可以对自述文件使用
hg sdiff README
和side-by-side mode中的diff
;但是,由于某种原因,当我运行shell时,上面的tput cols
输出仍然提供了80个字符。如果我从
hg sdiff
扩展删除sdiff
,则我的[pager]
将跨越整个终端宽度…[pager]
pager = LESS='FRX' less
## Removing sdiff fixes the problem with terminal width
attend = cat, diff, glog, log, incoming, outgoing, lg, show, lga
即使我从
sdiff
部分移除sdiff
并手动通过[pager]
作为less
管道,diff仍然跨越整个终端宽度。如何获得hg sdiff | less -FRX
和[extdiff]
以允许动态端子宽度用于并排差异? 最佳答案
我找到的唯一解决办法是
[extdiff]
# add new command that runs GNU diff(1) in 'side-by-side' mode
cmd.sdiff = sh
opts.sdiff = -c 'diff -dbB --left-column -y -W `tput cols` $0 $1 | less -FRX'
我还从
sdiff
部分删除[pager]
。这看起来像是一个变幻莫测的虫子。