Enable history in iex

Mon, Jun 28, 2021 0 min read
How to enable shell history in IEx REPL sessions and increase history size

After spending some time in iex, you want to run a past command, especially from previous sessions. Being used to irb or ipython, you hit the up arrow.

But, and nothing happens…

not working

Well, that is not enabled by default.

For that to work, add the following to your .zshrc or .bashrc

export ERL_AFLAGS="-kernel shell_history enabled"

And since the default history size is 512KB, let’s increase it.

export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_file_bytes 1024000"