Skip to content

Instantly share code, notes, and snippets.

@zoten
Forked from DaniruKun/.iex.exs
Created April 24, 2023 10:48
Show Gist options
  • Save zoten/64fa21f6cde78f32afef77ec21d589cc to your computer and use it in GitHub Desktop.
Save zoten/64fa21f6cde78f32afef77ec21d589cc to your computer and use it in GitHub Desktop.
My custom global IEx script file that is preloaded before each IEx session. Adds some convenience functions.
IO.puts("Using .iex.exs file loaded from #{__DIR__}/.iex.exs")
defmodule Util do
def atom_status do
limit = :erlang.system_info(:atom_limit)
count = :erlang.system_info(:atom_count)
IO.puts("Currently using #{count} / #{limit} atoms")
end
def cls, do: IO.puts("\ec")
def raw(any, label \\ "iex") do
IO.inspect(any,
label: label,
pretty: true,
limit: :infinity,
structs: false,
syntax_colors: [
number: :yellow,
atom: :cyan,
string: :green,
nil: :magenta,
boolean: :magenta
],
width: 0
)
end
end
defmodule :_exit do
defdelegate exit(), to: System, as: :halt
defdelegate q(), to: System, as: :halt
end
defmodule :_restart do
defdelegate restart(), to: System, as: :restart
end
defmodule :_util do
defdelegate cls(), to: Util, as: :cls
defdelegate raw(any), to: Util, as: :raw
end
import :_exit
import :_restart
import :_util
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment