mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 02:04:05 +00:00
Reorganize file structure: core/, utils/, modes/interactive/components/, modes/interactive/theme/
This commit is contained in:
parent
00982705f2
commit
83a6c26969
56 changed files with 133 additions and 128 deletions
28
packages/coding-agent/src/utils/clipboard.ts
Normal file
28
packages/coding-agent/src/utils/clipboard.ts
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import { execSync } from "child_process";
|
||||
import { platform } from "os";
|
||||
|
||||
export function copyToClipboard(text: string): void {
|
||||
const p = platform();
|
||||
const options = { input: text, timeout: 5000 };
|
||||
|
||||
try {
|
||||
if (p === "darwin") {
|
||||
execSync("pbcopy", options);
|
||||
} else if (p === "win32") {
|
||||
execSync("clip", options);
|
||||
} else {
|
||||
// Linux - try xclip first, fall back to xsel
|
||||
try {
|
||||
execSync("xclip -selection clipboard", options);
|
||||
} catch {
|
||||
execSync("xsel --clipboard --input", options);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
const msg = error instanceof Error ? error.message : String(error);
|
||||
if (p === "linux") {
|
||||
throw new Error(`Failed to copy to clipboard. Install xclip or xsel: ${msg}`);
|
||||
}
|
||||
throw new Error(`Failed to copy to clipboard: ${msg}`);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue