使用IEx(Elixir的REPL),我希望能够保存我的命令历史记录.
例如:
我可以打开一个新的IEx会话并执行命令.执行命令后,我可以按向上箭头并预先填充我的最后一个命令.关闭IEx并重新打开后,我想访问我的最后一个命令.
有没有办法做到这一点?
loe*_*chg 49
对于Erlang/OTP 20
这是内置的(来自https://hexdocs.pm/iex/IEx.html#module-shell-history)
从Erlang/OTP 20开始,可以通过传递一些在VM中启用它的标志来获取shell历史记录.这可以在启动IEx时按需要完成:
iex --erl "-kernel shell_history enabled"如果您希望在整个系统上启用它,则可以使用
ERL_AFLAGS环境变量并确保在终端/ shell配置中相应地设置它.在Linux [和macOS]上:
export ERL_AFLAGS="-kernel shell_history enabled"在Windows上:
set ERL_AFLAGS "-kernel shell_history enabled"
注意:@ andrei-sura提到你可能需要首先> touch ~/.iex_history在MacOS上
适用于Erlang/OTP 19及以下版本
尝试使用https://github.com/ferd/erlang-history
> git clone https://github.com/ferd/erlang-history.git
> cd erlang-history
> sudo make install # may not need sudo depending on installation
Run Code Online (Sandbox Code Playgroud)
Tra*_*ggs 17
我不知道事情是否在某个时刻发生了变化,但我发现上述方法不起作用。查看 iex 的手册页后,我注意到它需要
export ELIXIR_ERL_OPTIONS="-kernel shell_history enabled"
Run Code Online (Sandbox Code Playgroud)
(注意额外的 ELIXIR)。也许最初的解决方案是令人信服的,与 erl 相关(我发现它适用于此),但 iex 添加了限定符?由于最初的问题是针对 iex 的,因此认为应该更新它。
我正在使用 oh-my-zsh,所以我添加了vim ~/.zshrc:
# Enable history in IEX through Erlang(OTP)
export ERL_AFLAGS="-kernel shell_history enabled"
Run Code Online (Sandbox Code Playgroud)
那时source ~/.zshrc和现在总是加载。谢谢@loeschg。
| 归档时间: |
|
| 查看次数: |
3149 次 |
| 最近记录: |