From 937c2a450ce6af22168fda59e432aa2ab0b55605 Mon Sep 17 00:00:00 2001 From: nojhan Date: Sat, 23 Mar 2013 00:23:50 +0100 Subject: [PATCH] Add a JSON theme --- README.md | 4 ++++ colout_json.py | 8 ++++++++ 2 files changed, 12 insertions(+) create mode 100644 colout_json.py 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 +