diff --git a/packages/opencode/src/cli/cmd/tui/util/clipboard.ts b/packages/opencode/src/cli/cmd/tui/util/clipboard.ts index 7af1710668..4668f168ca 100644 --- a/packages/opencode/src/cli/cmd/tui/util/clipboard.ts +++ b/packages/opencode/src/cli/cmd/tui/util/clipboard.ts @@ -1,4 +1,3 @@ -import { $ } from "bun" import { platform, release } from "os" import clipboardy from "clipboardy" import { lazy } from "../../../../util/lazy.js" @@ -103,20 +102,18 @@ export namespace Clipboard { } export async function readPrimary(): Promise { - const os = platform() - if (os === "linux") { - if (process.env["WAYLAND_DISPLAY"] && Bun.which("wl-paste")) { - const text = await $`wl-paste --primary --no-newline`.nothrow().text() - if (text) return text - } - if (Bun.which("xclip")) { - const text = await $`xclip -selection primary -o`.nothrow().text() - if (text) return text - } - if (Bun.which("xsel")) { - const text = await $`xsel --primary --output`.nothrow().text() - if (text) return text - } + if (platform() !== "linux") return + if (process.env["WAYLAND_DISPLAY"] && which("wl-paste")) { + const result = await Process.text(["wl-paste", "--primary", "--no-newline"], { nothrow: true }) + if (result.text) return result.text + } + if (which("xclip")) { + const result = await Process.text(["xclip", "-selection", "primary", "-o"], { nothrow: true }) + if (result.text) return result.text + } + if (which("xsel")) { + const result = await Process.text(["xsel", "--primary", "--output"], { nothrow: true }) + if (result.text) return result.text } }