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

Do not display special characters in dos prompt #98

Closed
anborg opened this issue Mar 11, 2021 · 7 comments
Closed

Do not display special characters in dos prompt #98

anborg opened this issue Mar 11, 2021 · 7 comments

Comments

@anborg
Copy link

anborg commented Mar 11, 2021

Expected: Not to display special characters when displaying json

Actual: Displays special characters.

image

No special characters with curl

image

@anborg anborg changed the title special characters in dos prompt Do not display special characters in dos prompt Mar 11, 2021
@blyxxyz
Copy link
Collaborator

blyxxyz commented Mar 11, 2021

Ah, those are the colors. We should look for a way to detect when the terminal doesn't support them.

As a workaround you can disable colors completely by adding --pretty format.

Which version of Windows are you using? In newer versions ANSI colors should be turned on by default, I think. Maybe the instructions under "Enabling ANSI colors in older versions of Windows" on https://ss64.com/nt/syntax-ansi.html can fix it?

@ducaale
Copy link
Owner

ducaale commented Mar 11, 2021

Colors can also be disabled via the no_color env variable.

# current session only
set no_color=1   

# persist across sessions
setx no_color=1  

You could also use Windows Terminal which supports ANSI colors

Screenshot 2021-03-11 233110

@anborg
Copy link
Author

anborg commented Mar 12, 2021

Windows 10 - Pro
image

Interesting..

Windows Terminal, by default opened PoweShell tab which spewed error. Later I opened Dos inside it, no more special characters. Looks like I need to find a better terminal :)

Power shell ...

image

DOS... prompt?

image

@blyxxyz
Copy link
Collaborator

blyxxyz commented Mar 12, 2021

I think https://github.com/BurntSushi/termcolor might do the trick.

ripgrep uses it, so I'd be interested to know if it prints colors in the outdated DOS prompt that xh messes up. (If it just switches off colors then that would be progress too.)

@ducaale
Copy link
Owner

ducaale commented Mar 12, 2021

It seems ripgrep is able to output colors correctly in the old Windows Console

Screenshot 2021-03-12 180229


Windows Terminal, by default opened PoweShell tab which spewed error.

Not sure why but I am able to run the xh that I installed with scoop in Powershell

Screenshot 2021-03-12 180653

@ducaale
Copy link
Owner

ducaale commented Mar 12, 2021

Hmm, this is interesting. So it seems colors work when xh is run via cargo

Screenshot 2021-03-12 232419

But not when the executable is run directly

Screenshot 2021-03-12 233327

@ducaale
Copy link
Owner

ducaale commented Mar 16, 2021

xh v0.9.1 has been released which improves color support in windows 🎉

@ducaale ducaale closed this as completed Mar 16, 2021
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

3 participants