Skip to content

Instantly share code, notes, and snippets.

@estevanjantsk
Forked from DaniruKun/.iex.exs
Created May 27, 2024 12:38
Show Gist options
  • Save estevanjantsk/139e16d25dd9e829676e86fa1430e58b to your computer and use it in GitHub Desktop.
Save estevanjantsk/139e16d25dd9e829676e86fa1430e58b 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