Inside an “iex -S mix” session, is it possible to alias “r()” to “recompile()” ?
If in iex you do
h alias you will see that you can only alias a module, and you want to do it for a function.
As a side note they are two distinct functions as you can see by doing in iex
h r and
Interesting, I did not even realize, until now, that r/1 existed. How difficult is it to define a new r/0 ? Can this be achieved without recompiling mix, or is there no other way to do this?
You will want to try this:
While we are at it, you may want to take a look to:
defmodule Hauleth.IExHelpers do defdelegate r(), to: IEx.Helpers, as: :recompile defdelegate r!(), to: IEx.Helpers, as: :recompile! end import Hauleth.IExHelpers
According to the post I linked this will not work, it will throw:
But if you compile it first and then import it in
$HOME/.iex.exs it will work fine
I like your module simplicity.
For anyone else finding this via search, here is the full solution:
cat dev/iex/y.elixir defmodule Y.IExHelpers do defdelegate r(), to: IEx.Helpers, as: :recompile end
cat .iex.exs IEx.configure colors: [ eval_result: [:cyan, :bright ]] import Y.IExHelpers
iex -pa ~/dev/iex -S mix