Skip to content

Instantly share code, notes, and snippets.

@dguzzo
Last active August 29, 2015 14:03
Show Gist options
  • Save dguzzo/07e6bde0e02eb80859d9 to your computer and use it in GitHub Desktop.
Save dguzzo/07e6bde0e02eb80859d9 to your computer and use it in GitHub Desktop.
simple Node.js execute unix command and copy to clipboard
// inspired by http://www.dzone.com/snippets/execute-unix-command-nodejs
var exec = require('child_process').exec;
var someValue = "contrived: " + 2 * 2;
exec('echo "' + someValue + '" | pbcopy'); // "contrived: 4" is now in your clipboard. WARNING: this is destructive, and an overwrite something important if you're not careful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment