How to run a custom command when `iex -S mix` starts in dev mode

When I start an iex shell in my current project with iex -S mix, I often have to alias my models and load my ex_machina factory module like:

iex(1)> alias MyProject.{User, Account}
iex(2)> import MyProject.Factory

How can I automate this so that when iex -S mix starts in dev mode, the alias command (or imports) is run automatically so that I wont have to type it in everytime.

My apologies if this is something very basic and common knowledge.

Maybe iex.exs can help you. I’m not sure though if it is run before or after mix has been started.

Aside of that, pulling stuff implicitely into scope might be object of confusion later on.

2 Likes

Thank you so much ! Thats exactly what I was looking for !

My use-case is limited to creating quick, on-off test data from withing the iex shell itself and then using them.