Last active
November 3, 2022 23:14
-
-
Save antedeguemon/92609e90cc70e9ede041c4de9de61131 to your computer and use it in GitHub Desktop.
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 CustomIEx.Utils do | |
@doc """ | |
Puts some term into the clipboard | |
""" | |
def copy(data) do | |
# Copy to clipboard program depends on the OS | |
cmd = "pbcopy" ## --> mac | |
# cmd = "xclip -selection clipboard" ## --> linux | |
# cmd = "clip" ## --> windows | |
stringified_data = | |
data | |
|> inspect(pretty: true, limit: :infinity) | |
|> Macro.to_string() | |
{"", 0} = System.shell("echo #{stringified_data} | #{cmd}") | |
IO.puts("Copied to clipboard!") | |
end | |
end | |
import CustomIEx.Utils |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment