How to save IEx history?

With IEx (Elixir REPL) I would like to keep a history of commands.

For example:

I can open a new IEx session and run the command. After executing the command, I can press the up arrow and pre-populate my last command. After closing IEx and reopening, I would like to have access to my last commands.

Is there any way to do this?

+15
source share
2 answers

For Erlang / OTP 20

It is built-in (from https://hexdocs.pm/iex/IEx.html#module-shell-history )

You can get shell history from Erlang / OTP 20 by going through some flags that activate it in a virtual machine. This can be done as needed when starting IEx:

iex --erl "-kernel shell_history enabled"

, ERL_AFLAGS , ​​ /.

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
+33

oh-my-zsh, vim ~/.zshrc:

# Enable history in IEX through Erlang(OTP)
export ERL_AFLAGS="-kernel shell_history enabled"

. @loeschg.

0

All Articles