Httpie: Colorized output doesn't follow terminal ANSI color styles.

Created on 1 Oct 2016  路  9Comments  路  Source: httpie/httpie

HTTPie prefers solarized for its color palette, and it seems it doesn't properly follow whatever terminal style / colors that the end-user has set.

For example: I have specific ANSI colors set in my terminals, whether it be Terminal.app or HyperTerm on macOS, and yet, HTTPie still prefers solarized.

Terminal.app:


HyperTerm:


contributor-friendly feature

Most helpful comment

When I just change the formatter to self.formatter = TerminalFormatter() here, without any styles I get the correct colors from my iTerm profile (material design in my case, see the screenshot). Weird enough, using Terminal256Formatter with default styles results in ugly colors. I propose to set to TerminalFormatter by default and enable the other one only when the style flag is set.

~If this works for you I can open a PR: https://github.com/dsego/httpie/commit/9d3715d57be22e7121dd8088512c0250c57b1917~

screen shot 2016-12-04 at 12 27 09 pm

iTerm2 Dracula
screen shot 2016-12-04 at 12 31 06 pm

iTerm2 Monokai
screen shot 2016-12-04 at 12 31 20 pm

All 9 comments

@winneon There currently is no support for this. HTTPie uses color schemes from Pygments, with the exception of our solarized implementation.

There's the --style option by which can choose a theme:

  --style STYLE, -s STYLE
      Output coloring style (default is "solarized"). One of:

          algol, algol_nu, autumn, borland, bw, colorful, default,
          emacs, friendly, fruity, igor, lovelace, manni, monokai,
          murphy, native, paraiso-dark, paraiso-light, pastie,
          perldoc, rrt, solarized, tango, trac, vim, vs, xcode

      For this option to work properly, please make sure that the $TERM
      environment variable is set to "xterm-256color" or similar
      (e.g., via `export TERM=xterm-256color' in your ~/.bashrc).

What I believe could be done though is to create a custom theme whose colors would be dynamically assigned from the terminal ANSI color scheme.

That would be great! I'm not able to make a pull request at the moment because my PC's motherboard is out for replacement, but if there isn't a change implemented when I get it back, then I will take a look into that.

When I just change the formatter to self.formatter = TerminalFormatter() here, without any styles I get the correct colors from my iTerm profile (material design in my case, see the screenshot). Weird enough, using Terminal256Formatter with default styles results in ugly colors. I propose to set to TerminalFormatter by default and enable the other one only when the style flag is set.

~If this works for you I can open a PR: https://github.com/dsego/httpie/commit/9d3715d57be22e7121dd8088512c0250c57b1917~

screen shot 2016-12-04 at 12 27 09 pm

iTerm2 Dracula
screen shot 2016-12-04 at 12 31 06 pm

iTerm2 Monokai
screen shot 2016-12-04 at 12 31 20 pm

@dsego any updates on the pr?

@ivancuric I deleted my fork, there was no interest.

@dsego do you still have the code around? Completely missed your comment in the ocean of GitHub notifications.

@jkbrzt Sorry, scrubbed it. I think it was using TerminalFormatter instead of Terminal256Formatter when no style option is chosen.

@jkbrzt @ivancuric
Here is my second attempt. Not sure if this is the way to go. It works for me, but I don't know what it will do on different setups.

https://github.com/dsego/httpie/commit/b0fde07cfd8676a75292188dd8bedab7de74e6f2

So maybe I'm just crazy but it seems like this doesn't work when I choose the native theme? The colors that are outputted don't match anything in my terminal colors... I used to do the preset style before it was merged and it worked great, now it looks bad again, but native theme doesnt seem to fix it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Govinda-Fichtner picture Govinda-Fichtner  路  6Comments

rshurts picture rshurts  路  5Comments

jclem picture jclem  路  6Comments

chuma picture chuma  路  3Comments

hrj picture hrj  路  5Comments