Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Color full line of git status -s

Tags:

git

The command git status -s will output a short-format git status. The status of each file will be colorized, e.g. the M will be red or green; however, unlike the normal git status, the files will not be colorized. 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?

like image 867
Ben Kane Avatar asked Sep 29 '22 09:09

Ben Kane


1 Answers

This is not directly possible with native git, as the t/t7508-status.sh test script illustrates:

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.

See commit 75177c8 (27 Apr 2017) by Jeff King (peff).
See commit 93fdf30 (22 Apr 2017) by Stephen Kent (stevejameskent).
(Merged by Junio C Hamano -- gitster -- in commit 3900254, 16 May 2017)

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.

like image 50
VonC Avatar answered Oct 17 '22 08:10

VonC