watch 命令不显示“git status”的颜色

And*_*rei 18 colors git watch

我试图watch从“git status”中显示颜色。

我已经尝试使用该--color选项运行 watch ,正如此处其他地方所建议的那样,但仍然watch --color 'git status'不显示颜色。

jw0*_*013 18

git status在 下运行时watch,它能够检测到它的标准输出不是终端,这意味着如果color.status设置为则它不会输出颜色auto。要强制git status始终输出颜色(甚至低于watch),请设置color.statsalways,例如

git config color.status always
Run Code Online (Sandbox Code Playgroud)

永久设置的设置,或作为@ChrisJonsen指出,使用git -c color.status=always status运行git status与一次性覆盖。