Skip to content

Commit aed4247

Browse files
committed
fix(tui): update clipboard and paste handling for opentui 0.1.88
1 parent 82d5465 commit aed4247

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"
@@ -103,20 +102,18 @@ export namespace Clipboard {
103102
}
104103

105104
export async function readPrimary(): Promise<string | undefined> {
106-
const os = platform()
107-
if (os === "linux") {
108-
if (process.env["WAYLAND_DISPLAY"] && Bun.which("wl-paste")) {
109-
const text = await $`wl-paste --primary --no-newline`.nothrow().text()
110-
if (text) return text
111-
}
112-
if (Bun.which("xclip")) {
113-
const text = await $`xclip -selection primary -o`.nothrow().text()
114-
if (text) return text
115-
}
116-
if (Bun.which("xsel")) {
117-
const text = await $`xsel --primary --output`.nothrow().text()
118-
if (text) return text
119-
}
105+
if (platform() !== "linux") return
106+
if (process.env["WAYLAND_DISPLAY"] && which("wl-paste")) {
107+
const result = await Process.text(["wl-paste", "--primary", "--no-newline"], { nothrow: true })
108+
if (result.text) return result.text
109+
}
110+
if (which("xclip")) {
111+
const result = await Process.text(["xclip", "-selection", "primary", "-o"], { nothrow: true })
112+
if (result.text) return result.text
113+
}
114+
if (which("xsel")) {
115+
const result = await Process.text(["xsel", "--primary", "--output"], { nothrow: true })
116+
if (result.text) return result.text
120117
}
121118
}
122119

0 commit comments

Comments
 (0)