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
--
Ramakrishnan
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)
--Chouser
http://joyofclojure.com/
The repl is missing a lot of things a modern command line should have
- history, line editing, autocompletion, etc.
The already mentioned rlwrap can provide all of those. However, most
of the writeups on the web just use it, without noticing that the
syntax can be adjusted, and defaults to C-like syntax. I generally
fixed that by using --quote-chars='"' and --complete-filenames (the
latter removes / and . from the default set of break characters, which
may be why I haven't seen problems with the prompt color). The
other break chars just tweak autocompletion and word erase a little,
so I haven't really fooled with those.
<mike
--
Mike Meyer <m...@mired.org> http://www.mired.org/consulting.html
Independent Network/Unix/Perforce consultant, email for more information.
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org