Open bkovitz opened 6 years ago
I wonder about it too now since in a new project my custom REPL setup is not in user
ns, but in repl.user
.
I think I've come up with a solution by replacing rebel-readline.main
with a custom ns. It allows passing init-ns
as a CLI argument. See https://gist.github.com/metametadata/c11044a5d490eac7158ae535c10ce45c.
The relevant lines:
(defn -main
[& [init-ns]]
(rebel-core/ensure-terminal
(rebel-clj-main/repl*
{:init (fn []
(when (some? init-ns)
(let [init-ns (symbol init-ns)]
(require init-ns)
(in-ns init-ns))))
A command line argument, similar to clojure.main
's -i path/to/file.clj
, might be worth considering as part of this.
How, with the rebel-REPL (aka the rebl), do you set some initialization function to run when the REPL begins?
For example, to do this with the Leiningen REPL, I have this in my current project's
project.clj
::repl-options {:init (do (use 'farg.model1) (require '[farg.graphs :as g]))}
This way, I don't have to remember to manually set up those namespace aliases every time I start the REPL.