Skip to content

Instantly share code, notes, and snippets.

@macielsmith
Created March 26, 2018 21:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save macielsmith/18452e710a6b226f81152e21b2610287 to your computer and use it in GitHub Desktop.
Save macielsmith/18452e710a6b226f81152e21b2610287 to your computer and use it in GitHub Desktop.
prettify json files in git project before comparing
#!/bin/zsh
git diff --name-only | egrep '(dg5|df5|json)$' | xargs ~/.bin/prettify.rb
#!/usr/bin/env ruby
require "json"
filename = ARGV[0]
c = JSON.pretty_generate(JSON.parse(File.open(filename).read))
File.open(filename, "w").write(c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment