IEx Persistent History
# 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.
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:
export ERL_AFLAGS="-kernel shell_history enabled -kernel shell_history_file_bytes 1024000"
I learned about this functionality while looking through the Elixir FAQ, and there are some other things in their that folks might find interesting.