While working on kernel development, I like to keep track of what I'm doing in Evernote notes. Sometimes I like to copy a kernel panic or printk output from the console to the clipboard and put it into the note, but if I paste it inline it disrupts the readability of the note. I want to paste it in as an attachment.

To save steps, I streamlined the process by creating an app via the AppleScript Editor utility application using the code below.

set tmpf to "/Users/ecashin/tmp/pasteattach" & (random number from 0 to 10000) & ".log"
set fd to open for access tmpf with write permission
set txt1 to the clipboard as text
write txt1 to fd
close access fd

tell application "Evernote"
	set nb1 to selection
	set n1 to item 1 of nb1
	tell n1 to append attachment tmpf
end tell

If I had any real AppleScript aspirations I would have used "path to home" or whatever instead of hard coding my home directory. You'll have to type in your own home directory or do it the clean way. Also, make sure that ~/tmp exists if you want to use that directory as I do.

Now I can copy the trace, hit command+space to bring up spotlight, and type in the first few letters of my new application. When it comes up in the spotlight list, I hit enter. The clipboard contents are silently appended to the currently open note as an attachment.