Skip to content

Instantly share code, notes, and snippets.

@toringe
Last active August 29, 2015 14:27
Show Gist options
  • Save toringe/cf9d7237fdfd138641a5 to your computer and use it in GitHub Desktop.
Save toringe/cf9d7237fdfd138641a5 to your computer and use it in GitHub Desktop.
prettify and colorize JSON output from cURL, useful when interacting with REST API from console.
#!/bin/bash
#------------------------------------------------------------------------------#
# JSON cURL - prettify and colorize JSON output from cURL, useful when #
# interacting with REST API from console. #
# #
# Requirements: cURL, Python (JSON module) and Pygmentize #
# #
# Author: Tor Inge Skaar #
#------------------------------------------------------------------------------#
header=$( mktemp )
output=$( curl -s -D $header $@ )
echo -e "\e[90m"
cat "$header"
tput sgr0
echo $output | python -m json.tool | pygmentize -l json
rm -rf $header
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment