question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Color output of keys and values like jq

See original GitHub issue

Awesome project! I’m dealing now with a lot of yml files to be processed in kubernetes…

Is there a way to parse and print the key values in color?

Maybe just the same colors as jq or like in the vim editor?

screen shot 2018-01-26 at 12 51 27 am

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:20
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

22reactions
maximbazcommented, Oct 18, 2018

I think it’s still worth doing as part of yq itself, many people use cat a.json | jq . to preview highlighted and prettified json, it is so tempting to use cat b.yaml | yq -y . to achieve the same for yaml files.

It’s okay if pygments is not ideal, just redirect people to their repo in case someone wants to report an issue.

6reactions
kislyukcommented, Jan 28, 2018

You can pip install pygments and pipe the output of yq to pygmentize -l yaml to highlight in the terminal. Unfortunately the Pygments yaml highlighter is very drab and does not highlight much. https://bitbucket.org/birkenfeld/pygments-main/issues?q=yaml

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bonus: Coloring JQ's raw output - API Handyman
What we want to do now is coloring raw terminal output, ... a map with user-friendly color names as keys and ugly color...
Read more >
jq Manual (development version)
This can be useful when the values being output can contain newlines. ... This syntax only works for simple, identifier-like keys, that is,...
Read more >
jq Cheat Sheet - LZone
Output Formatting · jq Extraction Examples · “Deep” Value Extraction · Accessing unknown keys · Changing values with jq · Delete values with...
Read more >
JQ does not contain for "key": "value" JSON structure
The above filter gives the following output: { "name": "banana", "tags": [ { "id": ... If you want to exclude 'colored', use contains()...
Read more >
jq: colorize selected field of json file [closed]
If this is about how jq colorizes the output, have a look at man jq : ... like imitating the way jq colors...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found