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

`git rebase -i` shows ansi colour codes in editor

当我 运行 git rebase -i 时,我在常规待办事项列表(任何 repos,任何编辑器)之后显示 ansi 颜色代码,它们来自哪里?

谢谢。

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

好的,我设法解决了这个问题,这是因为我在 $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 生成变基待办事项列表,因此我的自定义 cat 污染了 git输出。

要解决此问题,只需将自定义 cat 重命名为其他名称即可。