Skip to content

Instantly share code, notes, and snippets.

@burhanrashid52
Created May 27, 2024 09:51
Show Gist options
  • Save burhanrashid52/d2fc4e87dfb44c0eda8e4b81413180a7 to your computer and use it in GitHub Desktop.
Save burhanrashid52/d2fc4e87dfb44c0eda8e4b81413180a7 to your computer and use it in GitHub Desktop.
// Name: Create Apple Note
// Shortcut: command option control a
import "@johnlindquist/kit"
import * as applescript from 'applescript';
function createAppleNoteScript(content: string) {
const title = 'Note created on ' + new Date().toLocaleDateString();
return `
tell application "Notes"
tell account "iCloud"
tell folder "Notes"
make new note with properties {name:"${title}", body:"${content}"}
end tell
end tell
end tell
`;
}
function createAppleNote(content: string) {
const script = createAppleNoteScript(content);
applescript.execString(script, (err: Error | null, result: any) => {
if (err) {
console.error('Error creating note:', err);
} else {
console.log('Note created successfully:', result);
}
});
}
const text = await editor("");
createAppleNote(text);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment