How to remove namespace name from sublimeREPL (clojure) prompt?
-
21-12-2019 - |
Question
I'm using clojure sublimeREPL and I would like to know if I can remove the namespace name from the prompt
Currently my prompt looks like this:
foo.core=>
More often for some reason it is doubled:
foo.core=>foo.core=>
I would like to be able to have just this:
>
I can't find the place where this behavior is defined in the sublimeREPL package
Any help welcome
Solution
As far as I can tell,lein repl
recognizes no argument for setting the prompt. Furthermore, the standard tools.nrepl
, as used by lein repl
, has the ability to set the prompt, but it is hidden inside a private function in cmdline.clj
and it is not exposed to any public function. So exposing this functionality would mean modifying both Leiningent and tools.nrepl.
Alternatively, the currently accessible way to set the prompt is as an argument to the function clojure.main/repl
. Sublime is not set up to interact directly with this, because it is set up to use the nrepl
protocol to communicate with Clojure.
So, unless I am missing something, your options are:
- accept that you cannot change the prompt
- change Leiningen and tools.nrepl so both expose a prompt option
- change Sublime so that it can use clojure.main/repl directly
OTHER TIPS
I know this is an old question, but there is a better answer than the accepted one. In your project.clj
file, you can set :repl-options
like so:
(defproject my-stuff "0.1.0"
:description "Leiningen Tutorial Project"
:url "http://example.com/FIXME"
:license {:name "MIT"
:url "http://opensource.org/licenses/MIT"}
:dependencies [[org.clojure/clojure "1.8.0"]]
:main ^:skip-aot my-stuff.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}}
:repl-options {
;; custom prompt
prompt (fn [ns] (str "> " ))
}
)
In your case, replace prompt (fn [ns] (str "> " ))
with prompt (str "> " )
and you should be all set.