zz_

app/tui/clipboard.ts

zzmq.dev@gmail.com/zz / app / tui / clipboard.ts @ 5e5720fb Download
Ladder Summary
  • file The module provides a macOS‑only clipboard utility. It exports a single function, **`copyToClipboard(text: string): void`**, which spawns the `pbcopy` command and streams the supplied text to its stdin, effectively copying the text to the system clipboard. No other functions or classes are exported.
// macOS only, matching this project's one supported platform -- pipe
// directly into pbcopy's stdin rather than shelling through a string.
// Extracted out of TabView.tsx, which had this exact function private
// to itself; AssistApp.tsx's own "y" shortcut needs the same thing.
import { spawn } from "node:child_process";

export function copyToClipboard(text: string): void {
  const proc = spawn("pbcopy");
  proc.stdin.write(text);
  proc.stdin.end();
}