My objective is to run a node.js CLI inside my devcontainer. I want to copy some text to the host clipboard inside the container.
This was super simple before running in a devcontainer, because on Mac OS I could call pbcopy
like this:
import { exec } from 'node:child_process';
const child = exec(command);
if (child.stdin) {
child.stdin.end(text); // This sends the text to the command's stdin
}
}
But this does not work in devcontainers. Tried with xclip
but get:
Authorization required, but no authorization protocol specified
Error: Can't open display: :1
Did anyone manage to get this to work?