简体   繁体   中英

How can I repeat the last line in the Clojure REPL?

In bash or Ruby's IRB, I can run a command or evaluate an expression, then use the up arrow on my keyboard to edit and rerun the same code. (This may be something I have configured, but I don't think so.)

This doesn't work for me in the Clojure REPL; I just see ^[[A typed when I press the up arrow.

Is there a way to "retype" the last line?

As mentioned in comments rlwrap is picking up where a native Clojure REPL is not "doing it", including arrow navigation, history and more.

However most (if not all) of the time Clojure is used together with lein , which has a built in REPL. Every time a Clojure REPL is needed, you can do:

lein repl

You don't necessarily need to have a project to start it, it can be started from anywhere (given that you have lein in your PATH ) and has many other very nice properties, which rlwrap won't give you.

To name a few:

  • If you run it form under the root of your project, it will load project's classpath, so you can interact with all the libs and code of your project.

  • It will also start an nREPL which you can connect to from anywhere (local/remote) including your favorite IDE/editors that are "nREPL capable". This would allow (for example) vim or emacs to use that REPL you started with lein repl to evaluate, compile, navigate (source) right from the editor.

  • Before it starts it reads and "obeys" ~/.lein/profiles.clj , where you can configure your sessions with pretty much anything you want: gpg keys, repl-options, dependencies, plugins, etc.. which will be loaded/configured on the lein repl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM