Skip to content

Instantly share code, notes, and snippets.

@beaulac
Created February 8, 2018 16:25
Show Gist options
  • Save beaulac/7c07f0d45d162df78ddc2b62c5df8a2c to your computer and use it in GitHub Desktop.
Save beaulac/7c07f0d45d162df78ddc2b62c5df8a2c to your computer and use it in GitHub Desktop.
Copy to clipboard w/ Node on Mac
const cp = require('child_process');
const clip = cp.exec('pbcopy', (_err, _stdout, _stderr) => {/* optionally do something */});
clip.stdin.write(aString);
clip.stdin.end(() => process.stdout.write(`\rCopied ${aString.length} characters.\n`));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment