Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save thomasjpr/9526a2d6d70609f456d0 to your computer and use it in GitHub Desktop.
Save thomasjpr/9526a2d6d70609f456d0 to your computer and use it in GitHub Desktop.
Create a new Markdown document in BBEdit and save the new file to a predetermined location, prompting the user to rename it. I keep all of my "notes" in a folder in my Dropbox.
tell application "BBEdit"
activate
make new document
set theDate to short date string of (current date)
set text of document 1 to theDate as text
save document 1 to "/Users/YOURUSERNAME/Dropbox/Notes/NewNote.md"
set old_name to name of text window 1
set dialog_result to display dialog "" default answer (theDate) & " - " & ¬
".md" buttons {"Cancel", "Save"} default button 2 ¬
with icon note ¬
with title "Create a New Note"
if button returned of dialog_result = "Save" then
set new_name to text returned of dialog_result
set d to active document of text window 1
if (d's on disk) then
set the_file to d's file
tell application "Finder"
set name of file the_file to new_name
end tell
else -- it's a document that has never been saved
set name of d to new_name
end if
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment