feat: initial project setup with gai tool
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export async function copyToClipboard(text: string): Promise<boolean> {
|
||||
const commands: string[][] = [];
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
commands.push(["pbcopy"]);
|
||||
} else if (process.platform === "linux") {
|
||||
commands.push(["xclip", "-selection", "clipboard"]);
|
||||
commands.push(["xsel", "--clipboard", "--input"]);
|
||||
}
|
||||
|
||||
for (const cmd of commands) {
|
||||
try {
|
||||
const proc = Bun.spawn(cmd, {
|
||||
stdin: "pipe",
|
||||
stdout: "ignore",
|
||||
stderr: "ignore",
|
||||
});
|
||||
proc.stdin.write(text);
|
||||
proc.stdin.end();
|
||||
const exitCode = await proc.exited;
|
||||
if (exitCode === 0) return true;
|
||||
} catch {}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user