export async function copyToClipboard(text: string): Promise { const commands: string[][] = []; if (process.platform === "darwin") { commands.push(["pbcopy"]); } else if (process.platform === "linux") { commands.push(["xclip", "-selection", "clipboard"]); commands.push(["xsel", "--clipboard", "--input"]); } for (const cmd of commands) { try { const proc = Bun.spawn(cmd, { stdin: "pipe", stdout: "ignore", stderr: "ignore", }); proc.stdin.write(text); proc.stdin.end(); const exitCode = await proc.exited; if (exitCode === 0) return true; } catch { // Try next command } } return false; }