psf / black

The uncompromising Python code formatter
https://black.readthedocs.io/en/stable/
MIT License
38.84k stars 2.45k forks source link

Coloured `--diff` output #994

Closed selurvedu closed 4 years ago

selurvedu commented 5 years ago

There is an option in diffutils:

--color [=when]

Specify whether to use color for distinguishing different contexts, like header, added or removed lines. when may be omitted, or one of:

  • none Do not use color at all. This is the default when no --color option is specified.
  • auto Use color only if standard output is a terminal.
  • always Always use color.

Specifying --color and no when is equivalent to --color=auto.

It would be nice if Black had a similar option, probably with a different name.

Peque commented 4 years ago

Ugly hack (ideally Black should be able to output with colors out-of-the-box):

black --diff . | colordiff
selurvedu commented 4 years ago

@Peque yeah, I used that workaround before.