Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globally disable color? #1073

Closed
saper opened this issue Jul 4, 2019 · 10 comments · Fixed by #1092
Closed

Globally disable color? #1073

saper opened this issue Jul 4, 2019 · 10 comments · Fixed by #1092
Labels

Comments

@saper
Copy link

saper commented Jul 4, 2019

I cannot find the way to globally disable color in the pre-commit output. Setting only the background color to green and not changing the foreground color does not work for my terminal with the following settings in the Xt resources (as set in the ${HOME}/.Xresources file):

Rxvt.background: black
Rxvt.foreground: deepSkyBlue

Is there a way? It would be great to respect https://no-color.org/ environment variable. And, while we are here, maybe understand the following git config setting:

[color]
        ui = never
@asottile
Copy link
Member

asottile commented Jul 4, 2019

There's --color

@saper
Copy link
Author

saper commented Jul 4, 2019

Thanks, how do i do this from the git pre-commit hook?

@asottile
Copy link
Member

asottile commented Jul 4, 2019

currently not an option afaik

@asottile
Copy link
Member

@saper would you like to implement $NO_COLOR or some such? shouldn't be too difficult to plug in here

@geieredgar
Copy link
Contributor

I submitted two PRs to disable color output via NO_COLOR environment variable (#1092) and deducing the right --color option from color.ui config value when run as git hook (#1091)

@saper
Copy link
Author

saper commented Jul 22, 2019

This is fantastic @geieredgar ! Thank you very very much!

@asottile
Copy link
Member

I've had more thought about this and I think NO_COLOR is kind of a bad standard and inflexible for pre-commit

@geieredgar would you mind reimplementing this as reading PRE_COMMIT_COLOR and having that be the default of the --color argparse option -- that would allow also forcing color on as well as off

@asottile asottile reopened this Jul 23, 2019
@geieredgar
Copy link
Contributor

@asottile Ok, I will submit a new PR soon.

@asottile
Copy link
Member

I'm also going to have TERM=dumb disable colors as well -- see #1103

@asottile
Copy link
Member

@geieredgar and @saper -- thanks again for the issue and implementation!

In the next minor release, pre-commit will have two ways to force color:

PRE_COMMIT_COLOR=...  # always, never, auto
TERM=dumb  # disables color

@pre-commit pre-commit locked as resolved and limited conversation to collaborators Jul 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants