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

How do I turn off colours? #4

Open
vi opened this issue Nov 7, 2024 · 6 comments
Open

How do I turn off colours? #4

vi opened this issue Nov 7, 2024 · 6 comments

Comments

@vi
Copy link

vi commented Nov 7, 2024

  1. How do I turn off the colours?
  2. How to make it assume white background, not dark background on terminal.

P. S. Multiple Rust tools that use coloured terminal output seem to assume black background by default and look poor in my setup. Maybe there is a cross-app way (e.g. a environment variable) to notify all the programs that the background is white?

@sectordistrict
Copy link
Owner

regarding point 1, for now I think a good setup would be to introduce a cli option that turns off the colors, I will have to see how I will work this out,
I suggest this workaround for your case: pipe into sed like the following intentrace ls | sed 's/\x1B\[[0-9;]\{1,\}[A-Za-z]//g' it also works when the background is whitish

for point 2 and the rest, I agree there's a general assumption that everyone uses dark mode terminals, however I think any thing in the vicinity of "working around a light/dark mode" of sorts for a terminal application will require intentionality in design to remedy, I don't believe there's a generalizable way of working around a white background terminal, however I'm interested in making this work so I'll prioritize this (most likely this will also be a cli option)

@thecaralice
Copy link

Try running with NO_COLOR=1. Most likely the library used for coloring understands that. See https://no-color.org/.

@vi
Copy link
Author

vi commented Nov 8, 2024

Yes, it does remove the colours.

Maybe there is another magical environment variable to map lighter colours to darker ones for light backgrounds?

@thecaralice
Copy link

Maybe there is another magical environment variable to map lighter colours to darker ones for light backgrounds?

I am not aware of any such consensus. There's NO_COLOR which explicitly disables usage of colors and CLICOLOR{,_FORCE} which control automatic detection of whether colors should be used. These three are semantically equivalent to --color={never,auto,always} some programs have.

You should consider changing your terminal color palette so that "bright" colors are actually darker, that would work for all programs using 3/4-bit colors.

@chapmanjacobd
Copy link

chapmanjacobd commented Dec 30, 2024

  1. How to make it assume white background, not dark background on terminal.

I agree with this point. I definitely prefer the colorized output but for light background terminals it would be more readable if the main foreground text color was black:

image

It shouldn't be too difficult to detect the color of the terminal background, eg. https://github.com/dalance/termbg

alternatively, having table output might be good enough to make NO_COLOR=1 mode more easy to scan through

@sectordistrict
Copy link
Owner

Thanks for the crate recommendation @chapmanjacobd
for now we'll simply switch the main text color depending on what termbg detects
artifacts like file descriptors and others seem like they'll only benefit from handpicked colors, to be addressed in the future
current updates pushed to 0.4.2 (tested on ayu_light, AtomOneLight, and 1984_light)

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

No branches or pull requests

4 participants