Skip to content

Instantly share code, notes, and snippets.

@amicojeko
Last active February 2, 2021 08:57
Show Gist options
  • Save amicojeko/ffd1288788473d24e5d70d51b78c0d95 to your computer and use it in GitHub Desktop.
Save amicojeko/ffd1288788473d24e5d70d51b78c0d95 to your computer and use it in GitHub Desktop.
Copy to clipboard with Ruby
# Windows and WSL
def clip_copy(input)
str = input.to_s
IO.popen('clip.exe', 'w') { |f| f << str }
str
end
# Mac
def clip_copy(input)
str = input.to_s
IO.popen('pbcopy', 'w') { |f| f << str }
str
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment