You can do it with simple nrepl middleware, for example:
(defn pprint-middleware [h]
(fn [{:keys [code op] :as msg}]
(if (and (= op "eval") (not (empty? code)))
(->> #(str "(clojure.pprint/pprint " % ")")
(update-in msg [:code])
h)
(h msg))))
The easiest way to add it to your repl is to config repl-options
in youe project.clj
:
:repl-options {:nrepl-middleware [nrepl.utils/pprint-middleware]})
Here is the full project.clj
example:
(defproject sample "0.1.0"
:dependencies [[org.clojure/clojure "1.4.0"]]
:repl-options {:nrepl-middleware [sample.utils/pprint-middleware]})