简体   繁体   English

颜色全线的git状态-s

[英]Color full line of git status -s

The command git status -s will output a short-format git status. 命令git status -s将输出短格式git状态。 The status of each file will be colorized, eg the M will be red or green; 每个文件的状态将被着色,例如M将是红色或绿色; however, unlike the normal git status , the files will not be colorized. 但是,与普通的git status ,文件不会着色。 They appear the default color for your terminal. 它们显示为终端的默认颜色。

Is there a way to colorize the files the same as their status' while still using the short-format output? 有没有办法在保持使用短格式输出的同时将文件着色为与其状态相同?

This is not directly possible with native git, as the t/t7508-status.sh test script illustrates: 这对于本机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

As you can see, the color is reset right after the short status indicator, and right before the filenames. 如您所见,颜色在短状态指示器之后立即重置,并且文件名之前


Note: the only evolution for now (Git 2.13.x/2.14, Q3 2017) is regarding the branches color. 注意:现在唯一的演变(Git 2.13.x / 2.14,Q3 2017)是关于分支颜色。

See commit 75177c8 (27 Apr 2017) by Jeff King ( peff ) . 请参阅Jeff King( peff 提交的75177c8 (2017年4月27日
See commit 93fdf30 (22 Apr 2017) by Stephen Kent ( stevejameskent ) . Stephen Kent( stevejameskent 提交的93fdf30 (2017年4月22日
(Merged by Junio C Hamano -- gitster -- in commit 3900254 , 16 May 2017) (由Junio C gitster合并- gitster - 提交3900254 ,2017年5月16日)

status : add color config slots for branch info in " --short --branch " status :在“ --short --branch ”中为分支信息添加颜色配置槽

Add color config slots to be used in the status short-format when displaying local and remote tracking branch information. 在显示本地和远程跟踪分支信息时,添加要在状态短格式中使用的颜色配置槽。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM