Excellent. Thank you both.

On Aug 27, 3:13 pm, Chouser <chou...@gmail.com> wrote:
> On Fri, Aug 27, 2010 at 9:48 AM, Ramakrishnan Muthukrishnan
>
> <vu3...@gmail.com> wrote:
> > On Fri, Aug 27, 2010 at 4:39 PM, frou <m...@frou.org> wrote:
> >> Is it or would it be possible to add some basic text colouring to the
> >> standard REPL (the one started with the "clj" shell script).
>
> >> It would be nice to be able to make the prompt, e.g. "user=>" coloured
> >> (green in my case) so that you get at-a-glance distinction between
> >> your inputs and the results printed.
>
> > If you use rlwrap to invoke the clojure repl, you can do that with
> > --prompr-colour option
>
> > eg;
>
> > rlwrap -p"red" java -cp blah blah clojure.main
>
> I didn't know about that.  Cool tip, but for me it pretty easily
> gets confused when the prompt changes (such as when moving
> between namespaces).
>
> I've been using this for a while -- not perfect either, but it
> attempts to print a green line before each prompt, and color
> return values blue.
>
> (defn my-repl []
>   (binding [*pprint* true]
>     (clojure.main/repl
>       :prompt #(printf
>                  "\033[32m-----\033[m\n%s=> "
>                  (ns-name *ns*))
>       :print (try
>                (fn [x]
>                  (print "\033[34m")
>                  (if *pprint*
>                    (clojure.pprint/pprint x)
>                    (prn x))
>                  (print "\033[m")
>                  (flush))
>                (catch Exception e
>                  (prn e))))))
>
> You can either just run (my-repl) at the REPL, or start Clojure
> with -e '(my-repl)'  If you then run a little test, you can see
> each of the different colors:
>
> (do (println "hi") 5)
>
> --Chouserhttp://joyofclojure.com/

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to