From: Silvio Rhatto Date: Thu, 23 May 2019 18:48:06 +0000 (-0300) Subject: Pretty printing aliases for JSON X-Git-Url: https://gitweb.fluxo.info/?a=commitdiff_plain;h=db1b5e010dfcb120b0e7f685ccefbcb311ed230e;p=rhatto%2Fdotfiles%2Fprofile.git Pretty printing aliases for JSON --- diff --git a/aliases.dot.link b/aliases.dot.link index 54717a7..d660066 100644 --- a/aliases.dot.link +++ b/aliases.dot.link @@ -59,3 +59,17 @@ alias s="shell" alias dquilt="quilt --quiltrc=${HOME}/.quiltrc-dpkg" alias dpkg-source='HOME=~/code/debian/keyring dpkg-source' alias dget='HOME=~/code/debian/keyring dget' + +# JSON +# See https://stackoverflow.com/questions/352098/how-can-i-pretty-print-json-in-a-shell-script#1920585 +prettyjson_string() { + echo "$1" | python -m json.tool +} + +prettyjson_file() { + python -m json.tool "$1" +} + +prettyjson_url() { + curl "$1" | python -m json.tool +}