Piping to jq, I get output like so:
Is there a way to change the color of null/boolean/number?
Something like:
export jq_int_color=yellow
export jq_bool_color=red
export jq_null_color=black
>Solution :
You can change the colors of different types of values with jq by setting the JQ_COLORS environment variable to a colon-delimited list of partial terminal escape sequences. For example, if you want to make null values red, false values green, true values blue, numbers yellow, strings magenta, arrays cyan, and objects white, you can use this command:
export JQ_COLORS='0;31:0;32:0;34:0;33:0;35:0;36:1;37'
The first number in each pair indicates the style (such as bright, dim, underscore, etc.), and the second number indicates the color (such as black, red, green, etc.). You can find more details and examples in the jq documentation.
The default JQ_COLORS values are a set of environment variables that control the color output of the jq command-line tool.
JQ_COLORS='0;31:0;39:0;39:0;39:0;39:0;39:0;39:0;39:0;39:0;39:0;39'
export JQ_COLORS_ERROR='1;31'
export JQ_COLORS_NULL='1;30'
export JQ_COLORS_FALSE='0;31'
export JQ_COLORS_TRUE='0;32'
export JQ_COLORS_NUMBER='0;33'
export JQ_COLORS_STRING='0;35'
export JQ_COLORS_ARRAY='1;37'
export JQ_COLORS_OBJECT='1;37'
export JQ_COLORS_KEY='0;33'
Each variable consists of a pair of numbers separated by a semicolon, which represent the ANSI escape codes for foreground and background colors. For example, 0;31 means black background and red foreground. You can change these values to customize the color scheme of jq.
