JSPM

  • Created
  • Published
  • Downloads 42420
  • Score
    100M100P100Q181795F

A command line utility that allows read/write (i.e copy/paste) access to the system clipboard.

Package Exports

  • copy-paste

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (copy-paste) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

node-copy-paste

A command line utility that allows read/write (i.e copy/paste) access to the system clipboard. It does this by wrapping pbcopy/pbpaste (for OSX), xclip (for linux), and clip (for windows). Currently works with node.js v0.8+.

The API

When require("copy-paste") is executed, two global functions are added:

  • copy(text[, callback]): asynchronously replaces the current contents of the clip board with text. Takes either a string, array, object, or readable stream. Returns the same value passed in. Optional callback will fire when the copy operation is complete.

  • paste([callback]): if no callback is provided, paste synchronously returns the current contents of the system clip board. Otherwise, the contents of the system clip board are passed to the callback as the second parameter.

    Note: Unfortunately, I'm having a hard time finding a synchronous version of child_process.exec that works on windows, so currently the synchornous version of paste (i.e. the version with no callback) only works on OSX and Linux.

If you do not want to pollute the global namespaced call require("copy-paste").noConflict(). It'll remove the copy and paste global functions as well as return an object that has copy and paste properties.

Getting node-copy-paste

The easiest way to get node-copy-paste is with npm:

npm install -g copy-paste

Rarely is it a good idea to install modules globally, but node-copy-paste is immensely useful while doing work in the REPL or while debugging. It's nice having it around.

Alternatively you can clone this git repository:

git clone git://github.com/xavi-/node-copy-paste.git

Future plans

I'm hoping to add various fallbacks for instances when xclip or clip is not avaiable (see experimental-fallbacks branch). Also this library needs to be more thoroughly tested on windows.

Developed by

  • Xavi Ramirez

License

This project is released under The MIT License.