]> gitweb.fluxo.info Git - rhatto/dotfiles/profile.git/commitdiff
Pretty printing aliases for JSON
authorSilvio Rhatto <rhatto@riseup.net>
Thu, 23 May 2019 18:48:06 +0000 (15:48 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Thu, 23 May 2019 18:48:06 +0000 (15:48 -0300)
aliases.dot.link

index 54717a79e4fb5ef64416ccdd291294ccba21c74e..d66006682f722020818eefc65be4ed5bcd7eadc4 100644 (file)
@@ -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
+}