Typescript ve macOS ile clipboard yonetimi, copy paste
programming, typescript
import { execSync } from 'child_process';
/**
* Copies text to the clipboard.
* @param text The text to be copied to the clipboard.
*/
export function copy(text: string): void {
execSync(`echo "${text.replace(/"/g, '\\"')}" | pbcopy`);
}
/**
* Returns the text from the clipboard.
* @returns The text from the clipboard.
*/
export function paste(): string {
return execSync('pbpaste').toString();
}
Bu kod, macOS işletim sistemi için bir clipboard yönetim aracıdır
İki fonksiyonu bulunur:
copy
vepaste
copy
fonksiyonu bir metni parametre olarak alır ve bu metni clipboard'a kopyalarpaste
fonksiyonu ise clipboard'daki metni geri döndürürBu kod,
child_process
modülününexecSync
fonksiyonunu kullanarak bu işlemleri gerçekleştirir
PreviousTypescript ile Websocket uzerinden zamanli bir sekilde mesaj gondermek, message queueNextDeleting files, completely, from git history
Last updated
Was this helpful?