Created
June 28, 2022 16:18
-
-
Save jondcallahan/9b7a664ab753b46bdc5c6e46a17e92e1 to your computer and use it in GitHub Desktop.
Copy to clipboard in Deno on macOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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