Skip to content

Instantly share code, notes, and snippets.

@jondcallahan
Created June 28, 2022 16:18
Show Gist options
  • Save jondcallahan/9b7a664ab753b46bdc5c6e46a17e92e1 to your computer and use it in GitHub Desktop.
Save jondcallahan/9b7a664ab753b46bdc5c6e46a17e92e1 to your computer and use it in GitHub Desktop.
Copy to clipboard in Deno on macOS
const encoder = new TextEncoder();
const process = await Deno.run({
cmd: ["pbcopy"],
stdin: "piped",
});
const stringToCopy = "hey hey";
await process.stdin.write(encoder.encode(stringToCopy));
process.stdin.close();
await process.status();
process.close();
console.log(`Copied ${stringToCopy} to clipboard`);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment