Skip to content

Instantly share code, notes, and snippets.

View mpatric's full-sized avatar

Michael Patricios mpatric

View GitHub Profile
@mpatric
mpatric / pj
Last active November 5, 2020 17:24
Pretty JSON output, with ANSI colour passthrough
#!/usr/bin/env ruby
require 'pty'
require 'json'
def prettify(s)
begin
s.scan(/^.*?(\{.*\}).*?$/).first.map do |f|
JSON.pretty_generate(JSON.parse(f)) rescue f
end
rescue