til

Today I Learned: collection of notes, tips and tricks and stuff I learn from day to day working with computers and technology as an open source contributor and product manager

View project on GitHub

Specify Colours

You can specify the colours used by jq -C by setting the JQ_COLORS environment variable. This works for the values not the keys etc.

Example:

export JQ_COLORS="5;36:0;39:0;39:1;37:5;33:1;39:1;50"; http https://jsonplaceholder.typicode.com/posts/1/comments | jq -C

The default settings are: JQ_COLORS=1;30:0;39:0;39:0;39:0;32:1;39:1;39

The positions in the list are as follows:

  1. color for null
  2. color for false
  3. color for true
  4. color for numbers
  5. color for strings
  6. color for arrays
  7. color for objects

The first value of the set:

  • 1 (bright)
  • 2 (dim)
  • 4 (underscore)
  • 5 (blink)
  • 7 (reverse)
  • 8 (hidden)

And the second:

  • 30 (black)
  • 31 (red)
  • 32 (green)
  • 33 (yellow)
  • 34 (blue)
  • 35 (magenta)
  • 36 (cyan)
  • 37 (white)

All of the above information is lifted from StackOverflow: “How do I customize the colors used by ‘jq -C’?”

Resources and References