`git rebase -i`在编辑器中显示ansi颜色代码

brc7rcf0  于 2023-04-04  发布在  Git
关注(0)|答案(1)|浏览(140)

当我运行git rebase -i时,我得到了ansi颜色代码,显示在常规的todo列表(任何repos,任何编辑器)之后,它们是从哪里来的?

  • git版本,尝试了2.13和2.15,我对我的用户设置进行了测试
  • color.uicolor.interactive都是false。
  • 在git config(core.editor)中尝试了vim,nano,subl和ed,都有这个问题

谢谢大家。

pick 5c0cbe059d56e2fe2bac4bf9e3373d5882157f4a commit
[38;5;252m# Rebase b4c6863..5c0cbe0 onto b4c6863 (1 command)[39m
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
o2gm4chl

o2gm4chl1#

好的,我设法解决了这个问题,这是因为我在我的$PATH中创建了一个自定义cat,它的内容是:

#!/bin/bash

if [[ ! -f $(which pygmentize) ]] ; then
  # if pygmentize not installed, use raw cat
  /bin/cat $@
else
  # pip install --user Pygments
  # html output: pygmentize -f html -O full,style=vim
  pygmentize -O style=native -f console256 -g $@;
fi

基本上它使用pygmentize来突出显示语法,我猜git使用cat来生成rebase todo列表,因此我的自定义cat污染了git输出。
要解决这个问题,只需将自定义cat重命名为其他名称。

相关问题