8
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ElixirのIExをElixirカラーにする

Last updated at Posted at 2021-10-30
  • IExのiex>をElixirカラーにする
  • その他、適宜IExの設定変更

イメージ

.iex.exsファイル

2種類あります

  • グローバル
    • $HOME/.iex.exs
    • すべてのElixirアプリに適用したい設定をおいておくところ
  • ローカル
    • my-app/.iex.exs
    • 各Elixirアプリごとにaliasとかをおいておくところ

IExのiex>はすべてのElixirアプリに使用されるので、グローバルの.iex.exsファイルに設定を書きます

ここに一例をあげますが、楽しいのでぜひ自由にカスタマイズしてみてください

~/.iex.exs
# どの iex.exs ファイルが使用されているかを表示
[:blue_background, :bright, :white, "Using config file: ", __ENV__.file]
|> IO.ANSI.format()
|> IO.puts()

# IExの設定
IEx.configure(
  inspect: [limit: 5_000],
  history_size: 100,
  # `iex>`のカスタマイズ(通常時)
  default_prompt:
    [:light_magenta, "%prefix>"]
    |> IO.ANSI.format()
    |> IO.chardata_to_string(),
  # `iex>`のカスタマイズ(分散ノード使用時)
  alive_prompt:
    [:light_magenta, "%prefix(%node)>"]
    |> IO.ANSI.format()
    |> IO.chardata_to_string()
)

# Phoenixアプリでよく使うmoduleはimportしておくと便利かも?
import_if_available(Plug.Conn)
import_if_available(Phoenix.HTML)
import_if_available(Ecto.Query)
import_if_available(Ecto.Changeset))

ローカル.iex.exsファイルには忘れずにグローバルの.iex.exsファイルをインポートしてください

my-app/.iex.exs
import_file_if_available("~/.iex.exs")

...

Nervesターゲット端末のIExをカスタマイズも可能です

資料

iex> h IEx.configure/1

おーはらさんのスライドに日本語で包括的に説明されています。Awesome!

8
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?