1.5.3 • Published 11 months ago

copy-paste v1.5.3

Weekly downloads
14,675
License
-
Repository
github
Last release
11 months ago

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, FreeBSD, and OpenBSD), and clip (for Windows). Currently works with node.js v0.8+.

The API

When require("copy-paste") is executed, an object with the following properties is returned:

  • 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. The first one being a potential error.

    	**Note**: The synchronous version of `paste` is not always available.  Unfortunately, I'm having a hard time finding a synchronous version of `child_process.exec` that consistently works on all platforms, especially windows.  An error message is shown if the synchronous version of `paste` is used on an unsupported platform.  That said, the asynchronous version of `paste` is always available.
  • require("copy-paste").global(): adds copy and paste to the global namespace. Returns an object with copy and paste as properties.

Example

var ncp = require("copy-paste");

ncp.copy('some text', function () {
  // complete...
})

Getting node-copy-paste

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

npm install -g copy-paste

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.

1.5.3

11 months ago

1.5.2

11 months ago

1.5.1

11 months ago

1.5.0

11 months ago

1.4.0

11 months ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.4

8 years ago

1.1.3

9 years ago

1.1.2

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.4

9 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

10 years ago

0.3.0

10 years ago

0.2.2

10 years ago

0.2.1

10 years ago

0.2.0

10 years ago

0.1.0

10 years ago

0.0.9

11 years ago

0.0.8

11 years ago

0.0.7

11 years ago

0.0.6

11 years ago

0.0.5

11 years ago

0.0.4

12 years ago

0.0.3

12 years ago