A great tool, when starting learning Elixir, is Elixir’s Interactive Shell (IEx), which allows you to type any Elixir expression and get its result. To start using IEx, open a terminal of your choice and type iex (or iex.bat if you are on Windows), which stands for Interactive Elixir.

By default, colors are not enabled and iex looks like what you see below:

It turns out that adding color to Elixir’s Interactive Shell is easy. Once you have opened Elixir’s Interactive Shell using:

> iex

you can enable colors by running the following command:

iex> Application.put_env(:elixir, :ansi_enabled, true) // turn colors ON
// OR
iex> Application.put_env(:elixir, :ansi_enabled, false) // turn colors OFF

Now, iex becomes a bit more colorful, and less tiring for the eyes:

In addition, if you want to change the color of iex prompt, e.g. turn it yellow, you may copy / paste the following script in iex:

IEx.configure(
  colors: [enabled: true],
  default_prompt: [
    "\e[G",    # ANSI CHA, move cursor to column 1
    :yellow,
    "%prefix", # IEx prompt variable
    ">",       # plain string
    :reset
  ] |> IO.ANSI.format |> IO.chardata_to_string
)

Categorized in:

Tagged in:

,