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

Colorized output doesn't follow terminal ANSI color styles. #524

Closed
winneon opened this issue Oct 1, 2016 · 9 comments
Closed

Colorized output doesn't follow terminal ANSI color styles. #524

winneon opened this issue Oct 1, 2016 · 9 comments
Labels
enhancement New feature or enhancement help wanted Extra attention is needed

Comments

@winneon
Copy link

winneon commented Oct 1, 2016

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:


@jkbrzt jkbrzt added the enhancement New feature or enhancement label Oct 28, 2016
@jkbrzt
Copy link
Member

jkbrzt commented Oct 28, 2016

@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.

@winneon
Copy link
Author

winneon commented Oct 28, 2016

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.

@jkbrzt jkbrzt added the help wanted Extra attention is needed label Oct 28, 2016
@dsego
Copy link
Contributor

dsego commented Dec 4, 2016

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: dsego@9d3715d

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

@ivancuric
Copy link

@dsego any updates on the pr?

@dsego
Copy link
Contributor

dsego commented Feb 20, 2017

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

@jkbrzt
Copy link
Member

jkbrzt commented Feb 20, 2017

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

@dsego
Copy link
Contributor

dsego commented Feb 21, 2017

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

@dsego
Copy link
Contributor

dsego commented Mar 6, 2017

@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.

dsego@b0fde07

@9mm
Copy link

9mm commented Jan 21, 2018

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or enhancement help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants