()
| 96 | let copyMethod: Promise<(text: string) => Promise<void>> | undefined |
| 97 | |
| 98 | function getCopyMethod() { |
| 99 | return (copyMethod ??= (async () => { |
| 100 | const { which } = await import("@opencode-ai/core/util/which") |
| 101 | const native = copyCommand(platform(), Boolean(process.env.WAYLAND_DISPLAY), (name) => Boolean(which(name))) |
| 102 | if (native?.[0] === "osascript") { |
| 103 | return async (text: string) => { |
| 104 | const escaped = text.replace(/\\/g, "\\\\").replace(/"/g, '\\"') |
| 105 | await command("osascript", ["-e", `set the clipboard to "${escaped}"`]).catch(() => undefined) |
| 106 | } |
| 107 | } |
| 108 | if (native) { |
| 109 | return async (text: string) => { |
| 110 | await command(native[0], native.slice(1), text).catch(() => undefined) |
| 111 | } |
| 112 | } |
| 113 | return async (text: string) => { |
| 114 | const { default: clipboardy } = await import("clipboardy") |
| 115 | await clipboardy.write(text).catch(() => undefined) |
| 116 | } |
| 117 | })()) |
| 118 | } |
| 119 | |
| 120 | export async function write(text: string) { |
| 121 | writeOsc52(text) |
no test coverage detected