Looking to make iex shell more easy to read and use

Hi everyone,

I am looking for a good config for an .iex file that can do the following:

Thanks in advance

1 Like

Managed to obtain colors like so:

IEx.configure(colors: [syntax_colors: [number: :magenta, atom: :cyan, string: :green,
 boolean: :magenta, nil: :magenta]])

All this config goes in the root of your project folder in an .iex.exs file that you have to create.
Now can someone explain how to format the output of the iex shell?

Thanks

2 Likes

It should get formatted automaitcally.

Though this depends on your terminal width.


Edit:

You can also provide the :width config option:

https://hexdocs.pm/iex/IEx.html#configure/1-width

1 Like

Thanks @NobbZ I will have a look over it. But can you offer an example of a good width to obtain something similar as in the example in my first post?

  1. It might be that the author manually wrapped the output for better readability and therefore not perfectly reproducable
  2. I’d guess its something in the range between 30 to 50.

Tried that didn’t work. Is there any way to make it look as in the picture maybe something like json formatter? That would be helpful or how can i build something like that.

For me it seems to work:

iex(1)> IEx.configure(width: 30)
:ok
iex(2)> [%{id: 1, name: "Jose", username: "josevalim"}]
[
  %{
    id: 1,
    name: "Jose",
    username: "josevalim"
  }
]
1 Like

Interesting i will share my config with you. Maybe we can find out what i did wrong thanks in advance

My config:

IEx.configure(
  colors: [
    syntax_colors: [
      number: :magenta,
      atom: :cyan,
      string: :green,
      boolean: :magenta,
      nil: :magenta
    ],
    width: 30
  ]
)

Does width need to be in front of colors?

This works

IEx.configure(
  width: 30,
  colors: [
    syntax_colors: [
      number: :magenta,
      atom: :cyan,
      string: :green,
      boolean: :magenta,
      nil: :magenta
    ]
  ]
)

For anyone needing to have something similar, the following config posted above works like a charm. Thanks for the help @NobbZ

5 Likes