MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / tryCopyViaPlatformTool

Function tryCopyViaPlatformTool

cli/src/utils/clipboard.ts:156–178  ·  view source on GitHub ↗
(text: string)

Source from the content-addressed store, hash-verified

154}
155
156function tryCopyViaPlatformTool(text: string): boolean {
157 const { execSync } = require('child_process') as typeof import('child_process')
158 const opts = { input: text, stdio: ['pipe', 'ignore', 'ignore'] as ('pipe' | 'ignore')[] }
159
160 try {
161 if (process.platform === 'darwin') {
162 execSync('pbcopy', opts)
163 } else if (process.platform === 'linux') {
164 try {
165 execSync('xclip -selection clipboard', opts)
166 } catch {
167 execSync('xsel --clipboard --input', opts)
168 }
169 } else if (process.platform === 'win32') {
170 execSync('clip', opts)
171 } else {
172 return false
173 }
174 return true
175 } catch {
176 return false
177 }
178}
179
180function tryCopyViaRenderer(text: string): boolean {
181 if (!registeredRenderer) return false

Callers 1

copyTextToClipboardFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected