我怀念在Windows上每次输入“git .*”命令时,都能看到绿色的暂存文件名和一些粗体等 Git 语法突出显示。
如何在 Mac 终端启用 Git 语法高亮?
如何在 Mac 终端启用 Git 语法高亮?
git config --global color.ui auto
要在 diff 命令中看到不同的颜色,请使用:
git config --global color.diff true
要为大多数命令全局更改颜色,请使用:
git config --global color.ui true
Git中的颜色
Git可以将其输出以彩色显示在终端上,这有助于您快速轻松地解析输出。许多选项可帮助您按照自己的喜好设置颜色。
color.ui
如果您要求,Git会自动为其大部分输出着色。您可以非常具体地指定您想要着色的内容和方式;但是要打开所有默认的终端着色,请将color.ui设置为true:
$ git config --global color.ui true
color.*
如果您希望更具体地了解哪些命令被标记了颜色以及如何标记,Git提供了特定于动词的着色设置。每个设置可以设置为true、false或always:
color.branch
color.diff
color.interactive
color.status
此外,每个设置都有子选项,您可以使用它来为输出的某些部分设置特定的颜色,以覆盖默认颜色。例如,要将差异输出中的元信息设置为蓝色前景、黑色背景和粗体文本,您可以运行:
$ git config --global color.diff.meta "blue black bold"
我使用了下面的解决方案:
git config --global color.diff auto
git config --global color.status auto
git config --global color.branch auto
git config --global color.diff true
git config --global color.status true
git config --global color.branch true
git config --global color.interactive true
有四种可用的设置类型:
~/gitconfig
文件中添加以下行:(这是我的 - 相当不错吧?)[color]
ui = auto
[color "branch"]
current = auto
remote = white reverse
[color "diff"]
meta = yellow bold
frag = magenta bold
new = green bold
[color "status"]
added = yellow bold
changed = green
untracked = cyan
colour.ui
设置为auto
。normal
,black
,red
,green
,yellow
,blue
,magenta
,cyan
和white
。bold
,dim
,ul
,blink
和reverse
。user.name/email
”设置为自我介绍后,将“color.ui”设置为“auto”作为第一件事。auto
”。