Created
January 30, 2023 19:58
-
-
Save dviramontes/e0927515fcde5e6df99c6bd1f14ecfdc to your computer and use it in GitHub Desktop.
Copy to paste buffer from within iex
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
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