sharkdp / pastel

A command-line tool to generate, analyze, convert and manipulate colors
Apache License 2.0
4.98k stars 97 forks source link

Add Check for PASTEL_COLOR_MODE if COLORTERM is empty or NOT in truecolormode #140

Closed yugonline closed 2 years ago

yugonline commented 3 years ago

121 @sharkdp

2021-06-21_20-52-01

Hopefully this should solve the issue. What do you think? It is a bit hacky , but... should work for all cases where COLORMODE is absent.

EDIT: attached the wrong screenshot.

sharkdp commented 3 years ago

Thank you for your contribution!

I don't think that's quite the behavior we want. PASTEL_COLOR_MODE, if set, should always overwrite COLORTERM values (both can be overwritten by the --color-mode flag). Please also take a look at this section:

https://github.com/sharkdp/pastel/blob/17c5ce03ef504e0b40f5b953e0763eea3aa202c9/src/cli/main.rs#L44-L89

which does the right thing for the normal output (just not for STDERR, which is used in pastel pick). And let me know if you need further help.

sharkdp commented 3 years ago

build error is unrelated to your branch. I will fix this in #141

yugonline commented 3 years ago

Okay I think I got a bit more understanding of requirements now. Initially I was thinking one of them has to be set. I will take a look at the file you mentioned and try to rewire it according to that. I was a bit confused because this code snippet you linked also uses the same function (as fallback) which the STDERR uses. So I thought just adding another check for PASTEL env would be enough. I think I was totally on the wrong path with this completely. Please give me some more time to fix this and also read a bit more thoroughly the code in general.

sharkdp commented 2 years ago

I'm closing this due to inactivity. Please feel free to comment in case it should be re-opened.