1

I'm trying to compress the output of git status a bit, for a "system status" script that runs whenever I log in to an ssh session. I'm hoping it'll nag at me and encourage me to commit more often!

git status | grep -v "git add\|git checkout\|no changes added"

Sadly it loses the coloring; any modified files are shown in the default font color, not red.

I've tried adding --color=never to the grep command, but that didn't make a difference, so I assume git status isn't adding color codes because of the pipe. Since a few commands in linux have --color=always to get over this, I tried adding that to git, but it just complained about an unknown option.

Thanks

0
1

I've discovered that you can add color options to the .git/config file in the project directory. This did exactly what I wanted:

[color]
status = always
1
  • 2
    Instead of editing .git/config by hand, it's better to use git config color.status always to do it for you. You can also add --global or --system to set the preferences for all your repositories at once. See man git-config for details. – TooTea Nov 20 '20 at 10:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.