Skip to content

Commit f550caa

Browse files
committed
fix(tui): update clipboard and paste handling for opentui 0.1.88
1 parent 77d3b1e commit f550caa

1 file changed

Lines changed: 12 additions & 15 deletions

File tree

packages/opencode/src/cli/cmd/tui/util/clipboard.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { $ } from "bun"
21
import { platform, release } from "os"
32
import clipboardy from "clipboardy"
43
import { lazy } from "../../../../util/lazy.js"
@@ -93,20 +92,18 @@ export namespace Clipboard {
9392
}
9493

9594
export async function readPrimary(): Promise<string | undefined> {
96-
const os = platform()
97-
if (os === "linux") {
98-
if (process.env["WAYLAND_DISPLAY"] && Bun.which("wl-paste")) {
99-
const text = await $`wl-paste --primary --no-newline`.nothrow().text()
100-
if (text) return text
101-
}
102-
if (Bun.which("xclip")) {
103-
const text = await $`xclip -selection primary -o`.nothrow().text()
104-
if (text) return text
105-
}
106-
if (Bun.which("xsel")) {
107-
const text = await $`xsel --primary --output`.nothrow().text()
108-
if (text) return text
109-
}
95+
if (platform() !== "linux") return
96+
if (process.env["WAYLAND_DISPLAY"] && which("wl-paste")) {
97+
const result = await Process.text(["wl-paste", "--primary", "--no-newline"], { nothrow: true })
98+
if (result.text) return result.text
99+
}
100+
if (which("xclip")) {
101+
const result = await Process.text(["xclip", "-selection", "primary", "-o"], { nothrow: true })
102+
if (result.text) return result.text
103+
}
104+
if (which("xsel")) {
105+
const result = await Process.text(["xsel", "--primary", "--output"], { nothrow: true })
106+
if (result.text) return result.text
110107
}
111108
}
112109

0 commit comments

Comments
 (0)