20

I'm trying to get watch to display colors from 'git status'.

I've tried running watch with the --color option, as suggested elsewhere here, but, still, watch --color 'git status' doesn't display colors.

Andrei
  • 1,713
  • 1
  • 15
  • 18
  • Are you sure your version of `watch` supports `--color`? – jw013 Aug 31 '12 at 14:18
  • related: [Prevent watch breaking colors](http://unix.stackexchange.com/q/41980/9537) – jw013 Aug 31 '12 at 14:20
  • @jw013: Yes, it's in the options list. – Andrei Aug 31 '12 at 16:51
  • 4
    Make sure colors are turned on for `git status`. Note that `auto` is insufficient for `watch` since output is not to a terminal. You'll have to `git config color.status always`, at least for running under `watch`. – jw013 Aug 31 '12 at 16:54
  • 7
    Git’s `-c` option can be used to set a value for `color.status` for a single command: `git -c color.status=always status` – Chris Johnsen Sep 01 '12 at 04:50
  • @jw013, setting `config.color.status` to `always` did the trick! If you just add that as an answer I'll mark it as 'accepted'. – Andrei Sep 03 '12 at 18:56

1 Answers1

26

When git status is run under watch, it is able to detect that its standard output is not a terminal, meaning it will not output colors if the color.status setting is set to auto. To force git status to always output colors (even under watch), set color.stats to always, e.g.

git config color.status always

to set the setting permanently, or as @ChrisJonsen points out, use git -c color.status=always status to run git status with a one-time override.

jw013
  • 50,274
  • 9
  • 137
  • 141