命令 git status -s
将输出短格式的 git status。每个文件的状态将被着色,例如M
将是红色或绿色;然而,与普通的 git status
不同的是,文件不会被着色。它们显示为您终端的默认颜色。
有没有办法在仍然使用短格式输出的同时将文件着色为与其状态相同的颜色?
最佳答案
这对于原生 git 来说是不可能的,因为 t/t7508-status.sh
测试脚本说明:
test_expect_success 'status with color.status' '
test_config color.status always &&
git status | test_decode_color >output &&
test_i18ncmp expect output
'
cat >expect <<\EOF
<RED>M<RESET> dir1/modified
<GREEN>A<RESET> dir2/added
<BLUE>??<RESET> dir1/untracked
<BLUE>??<RESET> dir2/modified
<BLUE>??<RESET> dir2/untracked
<BLUE>??<RESET> untracked
EOF
如您所见,颜色在短状态指示器之后和文件名之前重置。
注意:目前唯一的改进(Git 2.13.x/2.14,2017 年第 3 季度)是关于分支颜色。
参见 commit 75177c8 (2017 年 4 月 27 日)Jeff King (peff
) .
参见 commit 93fdf30 (2017 年 4 月 22 日)Stephen Kent (stevejameskent
) .
(由 Junio C Hamano -- gitster
-- merge 于 commit 3900254 ,2017 年 5 月 16 日)
status
: add color config slots for branch info in "--short --branch
"Add color config slots to be used in the status short-format when displaying local and remote tracking branch information.
关于git - git status -s 的彩色全行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29423742/