Skip to content

Instantly share code, notes, and snippets.

@dviramontes
Created January 30, 2023 19:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dviramontes/e0927515fcde5e6df99c6bd1f14ecfdc to your computer and use it in GitHub Desktop.
Save dviramontes/e0927515fcde5e6df99c6bd1f14ecfdc to your computer and use it in GitHub Desktop.
Copy to paste buffer from within iex
def copy(term) do
text =
if is_binary(term) do
term
else
inspect(term, limit: :infinity, pretty: true)
end
port = Port.open({:spawn, "pbcopy"}, [])
true = Port.command(port, text)
true = Port.close(port)
:ok
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment