Skip to content

Instantly share code, notes, and snippets.

@Bicarbona
Forked from luqmaan/write_to_clipboard.py
Created April 5, 2023 16:35
Show Gist options
  • Save Bicarbona/b95310bc697e4127ff5ee3dfd89e10bc to your computer and use it in GitHub Desktop.
Save Bicarbona/b95310bc697e4127ff5ee3dfd89e10bc to your computer and use it in GitHub Desktop.
Write a python string to the clipboard via pbcopy (OS X)
def write_to_clipboard(output):
import subprocess
process = subprocess.Popen('pbcopy', env={'LANG': 'en_US.UTF-8'}, stdin=subprocess.PIPE)
process.communicate(output.encode())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment