[英]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. 在bash或Ruby的IRB中,我可以运行命令或计算表达式,然后使用键盘上的向上箭头编辑并重新运行相同的代码。 (This may be something I have configured, but I don't think so.)
(这可能是我配置的内容,但我不这么认为。)
This doesn't work for me in the Clojure REPL; 这在Clojure REPL中对我不起作用; I just see
^[[A
typed when I press the up arrow. 我只看到
^[[A
当我按下向上箭头时输入。
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. 正如评论中所提到的,
rlwrap
正在拾取原生Clojure REPL不是“正在做”的地方,包括箭头导航,历史记录等。
However most (if not all) of the time Clojure is used together with lein
, which has a built in REPL. 然而,大多数(如果不是全部)时间Clojure与
lein
一起使用, lein
具有内置的REPL。 Every time a Clojure REPL is needed, you can do: 每次需要Clojure REPL时,您都可以:
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. 你不一定需要有一个项目来启动它,它可以从任何地方启动(假设你在你的
PATH
有lein
)并且有许多其他非常好的属性, rlwrap
不会给你。
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". 它还将启动一个
nREPL
,您可以从任何地方(本地/远程)连接,包括您喜欢的“nREPL能力”的IDE /编辑器。 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. 这将允许(例如)
vim
或emacs
使用您使用lein repl
启动的REPL来直接从编辑器进行评估,编译,导航(源代码)。
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
在它开始之前,它会读取并“服从”
~/.lein/profiles.clj
,您可以在其中配置几乎任何您想要的会话:gpg密钥,repl-options,依赖项,插件等...将被加载/在lein repl
上配置
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.