【问题标题】:Changing the lein repl prompt text更改 lein repl 提示文本
【发布时间】:2018-07-20 14:48:27
【问题描述】:

当我运行 lein repl 时,我会得到一个带有以下提示的精彩交互式 REPL

user=>

我碰巧在应用程序(作为控制台)上使用了 lein repl,我希望有类似的东西:

user(<environment>)=>

;; e.g. when run in production:
user(PRODUCTION)=>

当它用于访问环境中的 repl/console 时。

【问题讨论】:

标签: clojure leiningen read-eval-print-loop


【解决方案1】:

您可以将生产配置文件添加到您的 project.clj 并指定自定义提示功能:

:profiles {:production
           {:repl-options
            {:prompt (fn [ns] (format "%s(PRODUCTION)=> " ns))}}}

然后lein with-profile production repl。我想你可以在没有配置文件的情况下做同样的事情,但你的提示功能需要弄清楚它所处的环境。可能是这样的:

:repl-options {:prompt (fn [ns] (format "%s(%s) => " ns (System/getenv "HOME")))}

您可能还需要将 org.clojure/tools.nrepl 添加到您的依赖项中才能正常工作。

【讨论】:

  • 完美!我很幸运在env 上拥有特定环境,因此快速致电System/getenv 就像一个魅力。
猜你喜欢
  • 2017-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-11-28
  • 1970-01-01
  • 2012-12-31
  • 1970-01-01
  • 2014-10-26
相关资源
最近更新 更多