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

No color in Powershell when using pipes #245

Closed
cmust opened this issue Sep 19, 2024 · 2 comments
Closed

No color in Powershell when using pipes #245

cmust opened this issue Sep 19, 2024 · 2 comments

Comments

@cmust
Copy link

cmust commented Sep 19, 2024

Running this command

dir | moar

produces an output with no color.

The equivalent command (ls | moar) in other shells preserves the coloring as expected.

@walles
Copy link
Owner

walles commented Sep 19, 2024

I think the reason you're getting color from ls in this case is that you have some configuration enforcing color.

If you want color from dir you need to somehow get dir to color output not only to terminals but to pipes as well.

In GNU ls, you do this by passing --color=always. On BSD ls, setting CLICOLOR_FORCE to some value will force color.

What I expect, and what's probably happening with Powershell is this:

  • dir sees that its output is a pipe rather than a terminal
  • dir adapts by not showing any color
  • moar receives the not-colored stream and shows that

Do you get color from env -i /bin/ls | moar? If not, this demonstrates that you're somehow forcing ls to show color even when piping its output to somewhere else.

@walles
Copy link
Owner

walles commented Oct 26, 2024

No response, closing.

@cmust do re-open as needed!

@walles walles closed this as completed Oct 26, 2024
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

2 participants