1
votes

In my project I can run the command mix test --color which adds some colored output to the terminal. I would like to set this globally, so I can just run mix test and it automatically picks up that I want the output colored.

What I've tried...

  1. I've searched the online elixir docs about global configuration and global mix configuration.
  2. I've tried mix help too and couldn't see anything about global configuration.
  3. I've tried mix help test as well, it doesn't seem clear to me here how to add the option to the mix.exs file, or if it's possible to set global options somewhere.

I feel like this is probably possible, but after not coming up with anything I thought I'd ask here.

1

1 Answers

4
votes

I am not aware of the system-wide, global setting. It might be easily done, though, on a per-project basis with :aliases option given to what MyApp.MixProject.project/0 callback in your mix.exs file returns.

defmodule MyApp.MixProject do
  use Mix.Project

  def project do
    [
      app: :my_app,
      version: "0.1.0",
      ...
      aliases: [test: "test --color"], # this
      ...
    ]
  end
  ...

Aliases are designed to provide exactly this functionality: mix test would now call mix test --color under the hood.