I use TextMate on Mac OSX Mountain Lion to write notes. One thing I find myself needing a bunch is to insert the current date and time so I can track specific events. For instance if I am writing an article for Question-Defense.com and I am doing the initial formatting in TextMate, which is a typical scenario for me, I might take ten screenshots and I like to note the current date/time in case I get pulled away from the article writing for something else. So having a keyboard shortcut that outputs the current date/time is really valuable so I don’t have to type it out by hand. Below I describe how to install a OSX Service that will provide various date/time outputs via Keyboard Shortcuts. The OSX Service called WordService also provides a bunch of extra awesome services which I briefly touch on below as well.
Create Date And Time Output Via Keyboard Shortcut On Mac OSX Mountain Lion:
The examples below are tailored to TextMate however these instructions would work for anything that takes text input. Follow the steps below to enable the WordService OSX Service, enable the Services you are interested in, and then create Mac Keyboard Shortcuts to simplify your life! In all of the Terminal window examples below replace USERNAME with the name of your username to run the commands.
- Download WordService: First we need to download the WordService package from Devon Technologies by clicking here. The current version of WordService is 2.8 and I can confirm it works on OSX Mountain Lion without issue. Once you click on the referenced link scroll down a bit until you see WordService underneath the Freeware section. The filename of the download is WordService.zip. In this example it is expected that the WordService.zip file is downloaded to your users Downloads folder on the Mac computer where you are installing the eventual Keyboard Shortcut for inserting a date and time into a TextMate text file.
- Unpack WordService.zip: Double click on WordService.zip to create a folder called WordService in your Downloads folder. The full path for the new folder will be “/Users/USERNAME/Downloads/WordService”. Inside the WordService folder there will be some Readme files, a Version History text file, and a WordService.service directory as shown in the below example output.
- ak-mbp:~ alex$ ls -alh /Users/USERNAME/Downloads/WordService
- total 328
- drwxr-xr-x@ 8 alex staff 272B Feb 3 11:18 .
- drwx------ 191 alex staff 6.3K Feb 3 11:48 ..
- -rw-r--r--@ 1 alex staff 6.0K Feb 3 11:18 .DS_Store
- -rwxr-xr-x@ 1 alex staff 9.3K Nov 10 2010 Read Me (Čeština).rtf
- -rwxr-xr-x@ 1 alex staff 8.6K Nov 10 2010 Read Me (Français).rtf
- -rw-r--r--@ 1 alex staff 59K Nov 11 2010 Read Me.pdf
- -rw-r--r--@ 1 alex staff 70K Nov 10 2010 Version History.pdf
- drwxr-xr-x@ 3 alex staff 102B Nov 11 2010 WordService.service
- ak-mbp:~ alex$
- Create Services Directory: If you have previously installed services on your Mac then the Services directory may already exist however if you have not run the below command from a terminal window to create a Services directory underneath your Library folder.
- ak-mbp:Library alex$ mkdir /Users/USERNAME/Library/Services
- ak-mbp:Library alex$
- Copy WordService Directory Into Place: Now we need to copy or move the WordService directory into the proper location which is inside the Services directory we created above. Use the syntax below to copy the WordService directory into place.
- ak-mbp:Library alex$ mkdir /Users/USERNAME/Library/Services
- ak-mbp:Library alex$
- Enable WordService Mac OSX Service: To enable the WordService services you will need to logout and log back in to your Mac. Click the Apple icon in the top menu bar and select Log Out USERNAME to logout of your computer. You can immediately log back in which will pick up the WordService service and it will be enabled each time you login again moving forward.
- Modify Service Preferences: This tripped me up a bit when I first installed WordService as I assumed (I always assume but never should!) there would now be a WordService sub menu item underneath Services in the manu bar. The Services sub menu is located underneath the name of the active application in the top menu bar as shown in the below example image.
If you are familiar with the Services sub menu then you may already notice a couple new items however we want to enable the date and time output so first click on Services Preferences which will launch the Keyboard/Keyboard Shortcuts configuration window as shown in the below example image.
In the example image above notice the “Long Date” and “Long Date & Time” options located underneath the Services sub menu from the left column. There are also “Short Date & Time” and “Short Date” services that can be enabled if you scroll down a bit. To enable any of these items just make sure there is a check in the checkbox next to the title of the service. Adding the checkbox will make sure you can select the item from the Services sub menu within an application. One thing I like to do is assign a keyboard shortcut that I will actually remember to the service so you will notice above the Alt-U shortcut is different than what is displayed in your default WordService installation. To modify the keyboard shortcut simply double click on the current shortcut and then click the keys that you want to become the new keyboard shortcut and now you have created a new keyboard shortcut!
- Test Date & Time Insertion: Last but not least open TextMate or the other application you are going to use to insert the date and time. Once open click the keys that make up the keyboard shortcut you created above and check out the output!
- Short Date & Time: 1/28/13 12:28:53 PM
- Long Date & Time: Monday, January 28, 2013 12:28:56 PM
Be sure to checkout all of the other new services added by WordService. There are definitely some cool functions that you can now easily convert to a keyboard shortcut. The important thing for me though is the fact that I know can insert the current date and time in a TextMate file with a single click of two keys!
I don’t think you could have made this any harder or more intimidating for the average user. For the unix hack, dandy, but for anyone else, seriously?