There's AutoHotkey in Windows. This is a good thing to help me quickly insert the date time, enter [mm and then tap the space on it. In the Mac there is no such a good thing, although it can be achieved, but no autohotkey convenient. Still need to rely on AppleScript, but does not apply to any text input in the Mac place, such as DayOne pop-up window can not be used, there is another limit: Only the selected text can be manipulated.
I'm using the program in this article:
Http://www.sixhat.net/applescript-insert-date-and-time-into-your-documents.html
The code is:
--Insert Date and time into your documents--@2012 David rodriguesset Date_ to ((current Date) as String) set the Clipboar D to the Date_tell application "System Events" set Frontmostapplication to name of the first process whose frontmost are TrueEnd Telltell application Frontmostapplication activate tell application "System Events" keystroke "V" us ing {command} end Tellend tell
Note that it changes the contents of the pasteboard. I have defined a shortcut key for it: Cmd+alt+shift+f. Before use, you can first hit a letter, then select the letter, press this shortcut, it will show the date time. For example, the current time is: 2014-12-22-19:39:03 +0800.
The following English description is the following reference to the content of the first linked article, there is time to translate.
Below is a very simple AppleScript this inserts the date, time and timezone in the format that Jekyll requires.
Do shell script "date +%y-%m-%d\\%h:%m:%s\\%z"
To make inserting it simple, it's possible to assign a keyboard shortcut, by turning it into a Service in Automator.
Open Automator.app
Create a new Service
Set it to receive selected text on any application
Check the ' Output replaces selected text ' Tick-box
Insert the ' Run AppleScript ' action
Copy and paste the above AppleScript
Press Run to make sure it works
Save the .workflow
file to~/Library/Services
Open the Keyboard > Keyboard Shortcuts
System preference pane, select Services in the left column and then find the Service just created.
Assign a keyboard shortcut. I Use Command
+ Option
+d
There is one pitfall:it only works on selected text.
When saving a post for Jekyll, the File-name also requires a date-but not a time. For this, you can follow the same process as above with a modified AppleScript:
Do shell script "date +%y-%m-%d"
For this, I use the keyboard shortcut Command
+ + + Option
Shift
d
.
I would love it if the Service created the entire file name. So if the-the post title ' This is a post title ' were on the Clipboard, it would create a file called 2012-11-10-this-is-a-post-title.md
; replacing spaces WI th hyphens and converting it to lowercase. However, that's well beyond my very limited AppleScript knowledge.
Reference:
http://andytaylor.me/2012/11/10/creating-an-osx-service-to-insert-the-current-date-and-time/
http://www.question-defense.com/2013/01/28/ Title-osx-keyboard-shortcut-for-insert-date-and-time-insert-datetime-in-textmate
Quickly insert DateTime in Mac with shortcut keys