# Add to shell profile

export ERL_AFLAGS="-kernel shell_history enabled"

The ERL_AFLAGS variable is for setting a list of options which are added to the beginning of the erl command. In this case, we are adding the shell_history option for saving our shell history between sessions.

Note that “shell” here means either iex or erl , and if you use both, you’ll notice that the history is shared between them.

An example of IEx history. Use the up and down arrows to navigate the history.

The default number of bytes of history that are saved is 512KB. For my day-to-day work (where I am often copying large Elixir maps and structs from the logs and playing with them in IEx) this was not enough. To increase the limit, you can add the shell_history_file_bytes like this: