exbctel
exbctel

Reputation: 195

Can I add a newline to the Clojure REPL prompt?

I am a Python guy new to Clojure.

I like a bit of "air" around my REPL prompt. By air I mean a blank line between prompts.

In a Python REPL I can import sys and write sys.ps1='\n>>> '

Alternatively I could modify sys.ps1 in the code.interact source.

I found the following code in c:\clojure\src\clj\clojure\main.clj

(defn repl-prompt  
  "Default :prompt hook for repl"  
  []  
  (printf "%s=> " (ns-name *ns*)))

I added a newline at "\n%s=>" and fired up the REPL.

Wait ...that didn't work. <sad face>

My question is, why didn't it work?

I am using the basic Clojure 1.4.0 REPL on Windows XP (JVM=1.6.0).

Upvotes: 2

Views: 1883

Answers (1)

BLUEPIXY
BLUEPIXY

Reputation: 40145

E.g.

user=> (defn prompt [] (printf "my\n%s=>" (ns-name *ns*)))
#'user/prompt
user=> (clojure.main/repl :prompt prompt)
my
user=>

Upvotes: 3

Related Questions