Skip to content

Instantly share code, notes, and snippets.

@DaniruKun
Created January 31, 2023 16:44
Show Gist options
  • Save DaniruKun/ccbaad8720c203fd6d86a39722c63c51 to your computer and use it in GitHub Desktop.
Save DaniruKun/ccbaad8720c203fd6d86a39722c63c51 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