MCPcopy
hub / github.com/codeaashu/claude-code / copyOrWriteToFile

Function copyOrWriteToFile

src/commands/copy/copy.tsx:81–94  ·  view source on GitHub ↗
(text: string, filename: string)

Source from the content-addressed store, hash-verified

79 return filePath;
80}
81async function copyOrWriteToFile(text: string, filename: string): Promise<string> {
82 const raw = await setClipboard(text);
83 if (raw) process.stdout.write(raw);
84 const lineCount = countCharInString(text, '\n') + 1;
85 const charCount = text.length;
86 // Also write to a temp file — clipboard paths are best-effort (OSC 52 needs
87 // terminal support), so the file provides a reliable fallback.
88 try {
89 const filePath = await writeToFile(text, filename);
90 return `Copied to clipboard (${charCount} characters, ${lineCount} lines)\nAlso written to ${filePath}`;
91 } catch {
92 return `Copied to clipboard (${charCount} characters, ${lineCount} lines)`;
93 }
94}
95function truncateLine(text: string, maxLen: number): string {
96 const firstLine = text.split('\n')[0] ?? '';
97 if (stringWidth(firstLine) <= maxLen) {

Callers 2

CopyPickerFunction · 0.85
callFunction · 0.85

Calls 4

setClipboardFunction · 0.85
countCharInStringFunction · 0.85
writeToFileFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected