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

feature request: force colours #33

Closed
sinux-l5d opened this issue Dec 15, 2022 · 10 comments · Fixed by #38
Closed

feature request: force colours #33

sinux-l5d opened this issue Dec 15, 2022 · 10 comments · Fixed by #38

Comments

@sinux-l5d
Copy link

Hi,

I have a special case where I pipe my script using termcolor to fzf --ansi to keep colours. But it seems that _can_do_colour() wants stdout to be interactive, so this is not possible for now.

Would it be possible to init the module with forced colours?

@hugovk
Copy link
Member

hugovk commented Dec 16, 2022

It's possible by setting the FORCE_COLOR environment variable. Is that suitable for you?

I'm considering also adding force_color and no_color parameters, which could help #28 (comment) and #2 (comment) respectively.

@sinux-l5d
Copy link
Author

Works like a charm!
But indeed a parameter would be more suitable in some cases, when you want to pass an option to a script instead of prefixing it with a shell variable.
That will be ok in my case, thanks :D

@hugovk
Copy link
Member

hugovk commented Jan 15, 2023

Please see PR #38 to add parameters to override the environment variables.

@GergelyKalmar
Copy link

This would be very useful for me as well – in pytest-logikal I'm running some checks in a (non-interactive) subprocess but I'd still like to have the output be colored when collecting the results. Would there be any chance to merge PR #38 and release it?

@hugovk
Copy link
Member

hugovk commented Apr 22, 2023

Yes, I'll merge it now and release it in the next day or two, hopefully we can include #44 as well.

@GergelyKalmar
Copy link

That would be totally awesome! Thank you very much.

@hugovk
Copy link
Member

hugovk commented Apr 23, 2023

Released:

https://pypi.org/project/termcolor/2.3.0/

https://github.com/termcolor/termcolor/releases/tag/2.3.0

🚀

@doniks
Copy link

doniks commented Nov 16, 2023

are these options documented somewhere?

@hugovk
Copy link
Member

hugovk commented Nov 16, 2023

They're not, and they should be. Thanks for the prompt, I'll open an issue to make sure they're added.

@hugovk
Copy link
Member

hugovk commented Nov 18, 2023

Please see PR #60.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants