question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSON highlighting corrupted by green background in Windows Terminal

See original GitHub issue

Checklist

  • I’ve searched for similar issues.
  • I’m using the latest version of HTTPie.

Minimal reproduction code and steps

  1. Request a JSON file using HTTPie in Windows Terminal, e.g. http -j GET https://raw.githubusercontent.com/httpie/httpie/master/tests/fixtures/test.json
  2. Observe corrupt/incorrect green background in JSON syntax highlighting

Windows Terminal version 1.11.3471.0 Windows 10 21H2 (19044.1415) HTTPie 2.6.0 Python 3.10.1

JSON highlighting used to work correctly for me, but I’m not sure in exactly which version(s). I tested in Command Prompt, too, with the same result, so I don’t think this is specific to Windows Terminal.


Debug output

>http -j --debug GET https://raw.githubusercontent.com/httpie/httpie/master/tests/fixtures/test.json
HTTPie 2.6.0
Requests 2.27.1
Pygments 2.11.2
Python 3.10.1 (tags/v3.10.1:2cd268a, Dec  6 2021, 19:10:37) [MSC v.1929 64 bit (AMD64)]
C:\Users\will\scoop\apps\python\current\python.exe
Windows 10

<Environment {'colors': 256,
 'config': {'default_options': []},
 'config_dir': WindowsPath('C:/Users/will/AppData/Roaming/httpie'),
 'devnull': <property object at 0x000002A31B077A10>,
 'is_windows': True,
 'log_error': <function Environment.log_error at 0x000002A31B097010>,
 'program_name': 'http',
 'stderr': <colorama.ansitowin32.StreamWrapper object at 0x000002A31B089D80>,
 'stderr_isatty': True,
 'stdin': <_io.TextIOWrapper name='<stdin>' mode='r' encoding='utf-8'>,
 'stdin_encoding': 'utf-8',
 'stdin_isatty': True,
 'stdout': <colorama.ansitowin32.StreamWrapper object at 0x000002A31B089690>,
 'stdout_encoding': 'utf-8',
 'stdout_isatty': True}>

<PluginManager {'adapters': [],
 'auth': [<class 'httpie.plugins.builtin.BasicAuthPlugin'>,
          <class 'httpie.plugins.builtin.DigestAuthPlugin'>],
 'converters': [],
 'formatters': [<class 'httpie.output.formatters.headers.HeadersFormatter'>,
                <class 'httpie.output.formatters.json.JSONFormatter'>,
                <class 'httpie.output.formatters.xml.XMLFormatter'>,
                <class 'httpie.output.formatters.colors.ColorFormatter'>]}>

>>> requests.request(**{'auth': None,
 'data': '',
 'headers': {'User-Agent': b'HTTPie/2.6.0', 'Accept': b'application/json, */*;q=0.5', 'Content-Type': b'application/json'},
 'method': 'get',
 'params': <generator object MultiValueOrderedDict.items at 0x000002A31B178AC0>,
 'url': 'https://raw.githubusercontent.com/httpie/httpie/master/tests/fixtures/test.json'})

HTTP/1.1 200 OK
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Cache-Control: max-age=300
Connection: keep-alive
Content-Encoding: gzip
Content-Length: 180
Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
Content-Type: text/plain; charset=utf-8
Date: Tue, 11 Jan 2022 15:00:58 GMT
ETag: W/"020a89035cfd7a956c3a3db63baedb50bec31c5b8516170321eeb60c2f338f55"
Expires: Tue, 11 Jan 2022 15:05:58 GMT
Source-Age: 79
Strict-Transport-Security: max-age=31536000
Vary: Authorization,Accept-Encoding,Origin
Via: 1.1 varnish
X-Cache: HIT
X-Cache-Hits: 1
X-Content-Type-Options: nosniff
X-Fastly-Request-ID: 3f9a95965264c43c85ce6b1c6b891280811ce375
X-Frame-Options: deny
X-GitHub-Request-Id: B0CA:18E9:14CFB7:1AFE2C:61DD9B58
X-Served-By: cache-iad-kcgs7200037-IAD
X-Timer: S1641913258.082057,VS0,VE1
X-XSS-Protection: 1; mode=block

{
    "name": "Jakub Roztočil",
    "unicode": "χρυσαφὶ 太陽 เลิศ ♜♞♝♛♚♝♞♜ оживлённым तान्यहानि 有朋"
}

Additional information, screenshots, or code examples

image

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
isidenticalcommented, Jan 11, 2022

As as a quick workaround (until this issue gets resolved) you can actually set it as the default by adding the following to your config file (possibly located at %APPDATA%\httpie\config.json):

{
    "default_options": [
        "--style=auto"
    ]
}

We normally use fruity (a custom theme) as the default on windows (and auto on linux/mac os) because we had reports in the past that it was the best looking, though we probably should re-investigate this and perhaps use auto on all platforms. https://github.com/httpie/httpie/blob/508788ca5688bbdfba24b1a810d3091c78eccf46/httpie/output/formatters/colors.py#L30-L34

0reactions
FftyShadesofCodecommented, Jan 13, 2022

[image: image.png]

On Thu, Jan 13, 2022 at 7:14 AM Batuhan Taskaya @.***> wrote:

Hey @FftyShadesofCode https://github.com/FftyShadesofCode! Would you mind trying http --style=auto pie.dev/get and sending the output as a screenshot?

— Reply to this email directly, view it on GitHub https://github.com/httpie/httpie/issues/1266#issuecomment-1012082062, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHOQ6T5EZLMXNIN33K55MPDUV262PANCNFSM5LWSZ4OA . You are receiving this because you were mentioned.Message ID: @.***>

Read more comments on GitHub >

github_iconTop Results From Across the Web

Color schemes in Windows Terminal - Microsoft Learn
To demonstrate, let's change the color scheme for the Command Prompt profile. Look down the JSON file until you find the section that...
Read more >
How to Change Default JSON Editor in Windows Terminal ...
I newly installed Windows Terminal after downloading it directly from ... the highlight color changed from blue to a blueish green color.
Read more >
How to change color scheme on Windows Terminal
Windows Terminal lets you change the color scheme using the Settings UI and Settings.json file. Here's how and how to create schemes.
Read more >
Using console colors with Node.js - LogRocket Blog
But, by default, a Node.js app's output renders as simple white text on a black background. This means that it's easy to clutter...
Read more >
The minted package: Highlighted source code in LaTeX - CTAN
using the following command: $ sudo easy_install Pygments. Under Windows, you will not need the sudo, but may need to run the command....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found