Skip to content

Instantly share code, notes, and snippets.

@kaziridwan
Last active December 3, 2020 15:29
Show Gist options
  • Save kaziridwan/2a7907b7c499191bc3678c291ad06392 to your computer and use it in GitHub Desktop.
Save kaziridwan/2a7907b7c499191bc3678c291ad06392 to your computer and use it in GitHub Desktop.
Apple scripts for productivity
on zero_pad(value, string_length)
set string_zeroes to ""
set digits_to_pad to string_length - (length of (value as string))
if digits_to_pad > 0 then
repeat digits_to_pad times
set string_zeroes to string_zeroes & "0" as string
end repeat
end if
set padded_value to string_zeroes & value as string
return padded_value
end zero_pad
on run {input, parameters}
set d to (current date)
set yy to text -4 through -1 of (year of d as text)
set mm to text -2 through -1 of ("0" & (month of d as integer))
set dd to text -2 through -1 of ("0" & (day of d))
set hh to zero_pad(hours of d as integer, 2)
set mm to zero_pad(minutes of d as integer, 2)
set ss to zero_pad(seconds of d as integer, 2)
set datestring to yy & mm & dd & "-" & hh & mm & ss & "-"
tell application "System Events"
keystroke datestring
end tell
return datestring
end run
@kaziridwan
Copy link
Author

kaziridwan commented Dec 1, 2020

typethedate.workflow is inspired by this post

@kaziridwan
Copy link
Author

also, follow this thread to whitelist the script as well as the apps that uses the script

@kaziridwan
Copy link
Author

kaziridwan commented Dec 3, 2020

Updated the script with inspiration from Glutexo's gist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment