Last active
August 29, 2015 14:27
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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