Created
May 27, 2024 09:51
-
-
Save burhanrashid52/d2fc4e87dfb44c0eda8e4b81413180a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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