GithubHelp home page GithubHelp logo

cullophid / node-copy-paste Goto Github PK

View Code? Open in Web Editor NEW

This project forked from xavi-/node-copy-paste

0.0 2.0 0.0 388 KB

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

node-copy-paste's Introduction

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 OpenBSD), 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: The synchronous version of paste is not always availabled. 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 asyncchronous version of paste is always available.

  • require("copy-paste").noConflict(): removes copy and paste from the global namespace. Returns an object with copy and paste as properties. Can be chained with silent.

  • require("copy-paste").silent(): suppresses all print statements produced by this module, including ones that report errors. Returns an object with copy and paste as properties. Can be chained with noConflict.

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.

node-copy-paste's People

Contributors

xavi- avatar dbkaplun avatar cmtegner avatar moneal avatar vaskas avatar

Watchers

James Cloos avatar Andreas Møller avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.