Created
January 21, 2025 16:30
-
-
Save timm-oh/a5cb16b9e0ede9bd8b19f519b72bef25 to your computer and use it in GitHub Desktop.
shadow copy of https://shyr.io/blog/iex-copy-to-clipboard
This file contains 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
defmodule Helpers do | |
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