Created
June 12, 2025 20:34
-
-
Save chgeuer/1555d0e9615c21ca4132928e731ab40c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IO.puts("Using .iex.exs file loaded from #{__DIR__}/.iex.exs") | |
defmodule Util do | |
def iex(n), do: IEx.Helpers.v(n) | |
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 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 | |
def copy(term) do | |
text = | |
if is_binary(term) do | |
term | |
else | |
inspect(term, limit: :infinity, pretty: true) | |
end | |
case :os.type() do | |
{:win32, _} -> | |
port = Port.open({:spawn, "clip.exe"}, []) | |
true = Port.command(port, text) | |
true = Port.close(port) | |
{:unix, :linux} -> | |
port = Port.open({:spawn, "xclip"}, []) | |
true = Port.command(port, text) | |
true = Port.close(port) | |
{:unix, :darwin} -> | |
port = Port.open({:spawn, "pbcopy"}, []) | |
true = Port.command(port, text) | |
true = Port.close(port) | |
end | |
:ok | |
end | |
end | |
defmodule :_utildelegates do | |
defdelegate c, to: IEx.Helpers, as: :clear | |
defdelegate r, to: IEx.Helpers, as: :recompile | |
defdelegate exit(), to: System, as: :halt | |
defdelegate q(), to: System, as: :halt | |
defdelegate gui(), to: :observer, as: :start | |
defdelegate restart(), to: System, as: :restart | |
defdelegate raw(any), to: Util, as: :raw | |
end | |
import :_utildelegates | |
IEx.configure(default_prompt: "%prefix(%counter);") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment