Skip to content

Instantly share code, notes, and snippets.

@pathbreak
Last active March 7, 2023 13:10
Show Gist options
  • Save pathbreak/8dad3bcbe758c2912e289395e06279e1 to your computer and use it in GitHub Desktop.
Save pathbreak/8dad3bcbe758c2912e289395e06279e1 to your computer and use it in GitHub Desktop.
Pipe colorized jq JSON output to `more`

Pardon the SEO-optimized title but actually it doesn't look like more can handle it at all. Use less:

cat FILE.json | jq . -C | less -R

jq . -C :

  • '.' is the basic jq filter that pretty-prints JSON to stdout

  • -C : force jq to output ANSI color escape sequences ("ESC [... m") even when writing to a pipe

less -R :

  • Display ANSI color escape sequences on terminal.
@sodic
Copy link

sodic commented Mar 7, 2023

Pardon the SEO-optimized title but actually it doesn't look like more can handle it at all. Use less:

I actually opened this gist with the hope of adapting your more version into working with less 😄

Btw, I didn't know people still used more. I'd guess that mentioning less gives better SEO.

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