QuickSilver


QuickSilver is a program that most mac users know. It can find a file or run a application using the keyboard.

How it works is, you open QuickSilver with a keyboard shortcut and then write what you want. Then QuickSilver will do what you want. Since QuickSilver is blogged about quite a lot in the web, I will not write about it.


Day One


Day One is a diary application. It was first a iPhone application and then a Mac application was developed. So the syncing mechanism between the iPhone an Mac works quite well. Like QuickSilver Day One, there are a few blogs about Day One, so I will not write about it here.


Writing a Day One entry with QuickSilver


Day One has a menu bar to write a simple entry in it. But I sometimes wanted to use QuickSilver to write an entry in Day One. So I found the method and will write how it was done here.

Let me first show how an Day One entry can be made using QuickSilver. Open QuickSilver and write a text. (You can write a text by pressing the “.” button while QuickSilver is open) Then for the “Action” you choose “Send to Day One”. Then the text will become a Day One entry.

To make this possible you need two files.

The first file is the Day One command line interface (/usr/local/bin/dayone). You can get the install file from http://dayoneapp.com/tools/. Using the command line interface you can even write an entry using the terminal. So you can use the command line interface in many ways.

The second file you need is the “Send to Day One” script. This script will connect QuickSilver with the Day One command line interface. Here it is.
using terms from application "Quicksilver"
	on process text dayLog
		# Write input to Day One
		set returnString to do shell script "echo " & quoted form of dayLog & " | /usr/local/bin/dayone new"
		# There is a break line in the added entry. So this removes the  break line in added entry
		# Find path of file and correct path string.
		set cleanFileName to split(returnString, "New entry :") as string
		set tempFileName to split(cleanFileName, space)
		set fileName1 to item 2 of tempFileName
		set fileName2 to item 3 of tempFileName
		set fileName to fileName1 & "\\ " & fileName2
		#display dialog fileName
		# Copy file to temp file.
		do shell script "cp " & fileName & " " & fileName & ".tmp"
		# Delete and add </string> to correct poisition.
		do shell script "awk '{if($0 != \"<\\/string>\"){current=$0} else {prev=prev\"<\\/string>\";current=\"Tmwlak!!\";};if(prev!=\"Tmwlak!!\"){print prev;};prev=current}' " & fileName & ".tmp" & "> " & fileName
		# Add last line that wasn't written.
		do shell script "tail -1 " & fileName.tmp & " >> " & fileName
		# Remove first blank line.
		do shell script "sed -i \"\" 1d " & fileName
		# Remove temp file.
		do shell script "rm " & fileName & ".tmp"
		return nothing
	end process text 
end using terms from

– Functions for this script
to split(someText, delimiter)
	set AppleScript's text item delimiters to delimiter
	set someText to someText's text items
	set AppleScript's text item delimiters to {""} –> restore delimiters to default value
	return someText
end split

Save this script to ~/Library/Application Support/Quicksilver/Actions as Sent to DayOne.scpt. The tittle of the script will become the “Action” name.

Now you can write a Day One entry with QuickSilver


Reference