Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nvALT: Fix for "Append to nvALT journal" Alfred extension. Handling non-English characters as well.
on alfred_script(q)
set theYear to year of (current date) as string
set theMonth to (month of (current date) as number)
if theMonth < 10 then
set theMonth to "0" & theMonth
else
set theMonth to "" & theMonth
end if
set thisDate to (day of (current date) as number)
if thisDate < 10 then
set thisDate to "0" & thisDate
else
set thisDate to "" & thisDate
end if
set theDate to "" & year of (current date) & "-" & theMonth & "-" & thisDate
set theHours to (hours of (current date) as number)
if theHours < 10 then
set theHours to "0" & theHours
else
set theHours to "" & theHours
end if
set theMinutes to (minutes of (current date) as number)
if theMinutes < 10 then
set theMinutes to "0" & theMinutes
else
set theMinutes to "" & theMinutes
end if
set theTime to theHours & ":" & theMinutes
set temp to the clipboard
set the clipboard to (q as string & ".") -- "." is a dirty hack to fix the malbehavior of applescript.
tell application "nvALT"
activate
tell application "System Events"
keystroke "l" using {command down}
keystroke theDate & return & return & return
keystroke theTime & " -- "
key code 9 using {command down} -- Command+v
keystroke return
-- Change this part to your global hotkey
keystroke "e" using {command down, control down}
end tell
end tell
delay 0.5
set the clipboard to temp
end alfred_script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment