Clojure 更改lein repl提示文本
当我运行leinrepl时,我得到了一个很棒的交互式repl,提示如下Clojure 更改lein repl提示文本,clojure,leiningen,read-eval-print-loop,Clojure,Leiningen,Read Eval Print Loop,当我运行leinrepl时,我得到了一个很棒的交互式repl,提示如下 user=> 我碰巧在一个应用程序上使用了lein repl作为控制台,我希望有如下功能: user(<environment>)=> ;; e.g. when run in production: user(PRODUCTION)=> 当用于在环境中访问repl/控制台时。您可以将生产配置文件添加到project.clj并指定自定义提示功能: :profiles {:production
user=>
我碰巧在一个应用程序上使用了lein repl作为控制台,我希望有如下功能:
user(<environment>)=>
;; e.g. when run in production:
user(PRODUCTION)=>
当用于在环境中访问repl/控制台时。您可以将生产配置文件添加到project.clj并指定自定义提示功能:
:profiles {:production
{:repl-options
{:prompt (fn [ns] (format "%s(PRODUCTION)=> " ns))}}}
然后,莱因与配置文件制作回复。我想您可以在没有概要文件的情况下做同样的事情,但是您的提示函数需要确定它所处的环境。也许是这样的:
:repl-options {:prompt (fn [ns] (format "%s(%s) => " ns (System/getenv "HOME")))}
您可能还需要将org.clojure/tools.nrepl添加到您的依赖项中,以使其生效。链接到lein的:repl选项,请参阅:提示键。这些问题强调了clojure现在是一种成熟的生产型企业语言-完美的我很幸运在env上有特定的环境,所以快速调用System/getenv非常有用。