Remember iEX history

I'm often finding myself crafting some of the most complex and ingenious stuff ever known to IEx men, only to find myself having to recreate it minutes later because I'm now in a new IEx session. Annoying? Yes. Solvable? Yes! Here's how.

We're all familiar with using Ctrl+r for searching our shell history of crafty one-liners, right? Great. With that out of the box, let's see how we can achieve the same in iEX. It's quite simple, and it's well explained in the IEx documentation.

Enabling it for single sessions can be done by starting IEx in the following way:

iex --erl "-kernel shell_history enabled"

Enabling it system-wide can be done by setting the following environment variable (Unix-like systems):

export ERL_AFLAGS="-kernel shell_history enabled"

Now, once you've done this you can enjoy having all of your IEx history available using the arrow up and arrow down keys, as well as the Ctrl+r trick mentioned earlier.