diff --git a/README.md b/README.md index 63cd258..f999fa2 100644 --- a/README.md +++ b/README.md @@ -120,3 +120,7 @@ special characters that would be recognize by your shell. * Color a source code in 256 colors mode: `cat colout.py | colout Python monokai` + +* Color a JSON stream: + `echo '{"foo": "lorem", "bar":"ipsum"}' | python -mjson.tool | colout -t json` + diff --git a/colout_json.py b/colout_json.py new file mode 100644 index 0000000..a4c8a0b --- /dev/null +++ b/colout_json.py @@ -0,0 +1,8 @@ + +import colout +def theme( item ): + item = colout.colorup( item, '[{}]' ) + item = colout.colorup( item, '[:,]', "blue" ) + item = colout.colorup( item, '".*"', "green" ) + return item +