Skip to content

Instantly share code, notes, and snippets.

@antedeguemon
Last active November 3, 2022 23:14
Show Gist options
  • Save antedeguemon/92609e90cc70e9ede041c4de9de61131 to your computer and use it in GitHub Desktop.
Save antedeguemon/92609e90cc70e9ede041c4de9de61131 to your computer and use it in GitHub Desktop.
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