Today I Learned

hashrocket A Hashrocket project

Pretty Print JSON responses from `curl` - Part 3

If you thought that the output was pretty enough from last TIL, you were wrong.

Dennis Carlsson tweeted me about a tool called bat that has automatically syntax highlighting for a bunch of different languages and can also display line numbers.

Just pipe bat after jq and you are good to go:

> curl 'https://til.hashrocket.com/api/developer_posts.json?username=gabrielreis' | jq  | bat

       │ STDIN
───────┼──────────────────────────────────────────────────────────────────────────────
   1   │ {
   2   │   "data": {
   3   │     "posts": [
   4   │       {
   5   │         "title": "Pretty Print JSON responses from `curl` - Part 2",
   6   │         "slug": "utpch45mba"
   7   │       },
   8   │       {
   9   │         "title": "Pretty Print JSON responses from `curl`",
  10   │         "slug": "pgyjvtuwba"
  11   │       },
  12   │       {
  13   │         "title": "Display line break content in React with just CSS",
  14   │         "slug": "mmzlajavna"
  15   │       }
  16   │     ]
  17   │   }
  18   │ }

If you know any other tricks on making stdout prettier I would love to learn them.

See More #command-line TILs