Skip to content
The clipboard copy/paste API for Deno
TypeScript Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

Files

Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows
LICENSE.md
README.md
example1.ts
example2.ts
example3.ts
mod.ts
test.sh
test.ts

README.md

Deno clipboard library

Build Status
(CI tests on Linux, Mac, Windows)

Usage

import { clipboard } from 'https://deno.land/x/clipboard/mod.ts';

await clipboard.writeText('some text');

const text = await clipboard.readText();

console.log(text === 'some text'); // true

Goals

  • use Web Clipboard API
  • use readText and writeText (no read and write, see the spec)
  • work on Linux, macOS, Windows
  • don't bundle any binaries

It will spawn external processes so unfortunately it will require the all-powerful --allow-run flag.

If Deno exposes a Clipboard API (with new permissions like --allow-copy and --allow-paste) then hopefully this will be obsolete. See the relevant issue:

Notes

On Linux it requires xsel to be installed (probably installed by default).

The clipboard on Windows always adds a trailing newline if there was none which makes single line strings end with a newline and this module removes the trailing newline on Windows, but it means that if it was there originally then it will still be removed - to preserve single-line strings being single-line, but maybe this is not the right way to do it. The other option would be to preserve the trailing newline but also to get one if it wasn't there. Currently I chose to remove it because newlines in the clipboard sometimes are problematic (like automatically starting commands when pasted into the terminal). TODO: think about it.

Issues

For any bug reports or feature requests please post an issue on GitHub.

Author

Rafał Pocztarski
Follow on GitHub Follow on Twitter
Follow on Stack Exchange

License

MIT License (Expat). See LICENSE.md for details.

You can’t perform that action at this time.