How do I save IEx history?

For Erlang/OTP 20

This is built-in (from

From Erlang/OTP 20, it is possible to get shell history by passing
some flags that enable it in the VM. This can be done on a per-need
basis when starting IEx:

iex --erl "-kernel shell_history enabled"

If you would rather enable
it on your system as a whole, you can use the ERL_AFLAGS environment
variable and make sure that it is set accordingly on your
terminal/shell configuration.

On Linux [and macOS]:

export ERL_AFLAGS="-kernel shell_history enabled"

On Windows:

set ERL_AFLAGS "-kernel shell_history enabled"

To show where the history file is located, run the following code from erl (Mac OS example value shown):

1> filename:basedir(user_cache, "erlang-history")

To set the file to a different location, use the shell_history_path /path/to/history-file option from the erlang docs (compatible with Elixir/iex):

export ERL_AFLAGS="-kernel shell_history_path '\"$HOME/.erlang-history\"'"

For Erlang/OTP 19 and below

Try using

> git clone
> cd erlang-history
> sudo make install    # may not need sudo depending on installation

Leave a Comment