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

Low contrast for null coloring #2113

Closed
mcandre opened this issue May 6, 2020 · 3 comments · Fixed by #2824
Closed

Low contrast for null coloring #2113

mcandre opened this issue May 6, 2020 · 3 comments · Fixed by #2824

Comments

@mcandre
Copy link

mcandre commented May 6, 2020

Describe the bug

null values are colorized with a low-contrast, almost black foreground that makes the value nearly invisible on many terminals.

To Reproduce

  1. Set Terminal.app to "Homebrew" theme.
  2. Process a null value through jq onto stdout.

Expected behavior

The null should be clearly visible.

Environment (please complete the following information):

  • OS and Version: macOS Catalina
  • jq version 1.6
@itchyny
Copy link
Contributor

itchyny commented May 7, 2020

You can configure the coloring with JQ_COLORS environment variable (see reference). For example, following configuration changes the color of null.

export JQ_COLORS="0;37:0;37:0;37:0;37:0;32:1;37:1;37"

When we change the default color of null, some say that it's too bright, so it's unlikely to change the default colors.

@ratkins
Copy link

ratkins commented Sep 23, 2020

I just wasted a 2 hour round trip change to a CI script because of this. I tested jq's behaviour on the command line first, because I'm smart:

Screenshot 2020-09-23 at 15 42 43

"Ok, great", I thought. "In my script I'll assign the output of jq to a variable and test if that variable is empty to see if my json has an id key. But it didn't work! Then I attempted to re-create the issue from my command line like this:

floater@xxxxxxxxxxxxxxxxxxxxxxxx % RESULT=$(echo "{\"foo\": \"42\"}" | jq .id) 
floater@xxxxxxxxxxxxxxxxxxxxxxxx % echo $RESULT
null

The penny only dropped when I went to copy-and-paste the original lines (from the screenshot) into a Slack channel, and then I saw the black-on-black null.

Why would I have any reason to think the output of an (explicitly scriptable!) command line Unix tool would be coloured? jq should not use terminal colours by default.

@vincentbernat
Copy link

The default value, 1;30, means bold black. That's how this is documented for xterm. On Linux, anything based on VTE (Gnome terminal) will just display pitch black. While not part of VT100, there is the ability to use 0;90 to get a "bright" black. This is also documented for xterm as an aixterm extension. It's implemented in VTE terminals as well. It seems a better default than bold black and should give the same results on terminals already changing bold black to bright black when on black background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants