SubEthaEdit as a Journal

I really like SubEthaEdit, a text editor for Mac. It’s mostly geared towards programming, but I find that it’s a really good editor for anything text-only. For example, my journal is plaintext to avoid file format changes.

I created a script for use within SubEthaEdit’s AppleScript menu. It’s silly stupid, and doesn’t scratch the surface of what SEE’s scripts can do but it fits my needs (laziness). Basically, I wanted the same template for all my entries so if I ever want to process them, I have labeled metadata to work with. I also wanted to automatically save them into my Journal directory with a timestamp for sorting.

I know there are other journals, heck I could even use Blogger. But I don’t trust online security and other Journal apps either lock you into a file format or are bloated (or both). 
So here’s my script. I hope it’s useful to someone.

on seescriptsettings()
return {keyboardShortcut:"^~@n", displayName:"TKJournal", inContextMenu:"no"}
end seescriptsettings

-- You should type and select the title before invoking this script
tell application "SubEthaEdit"
set mySelection to contents of selection of front document as text
set myHeader to "title: " & mySelection & return
set myHeader to myHeader & "Date: " & (current date) & return
set myHeader to myHeader & "Category: " & "Personal" & return
set myHeader to myHeader & "Tags: " & "journal" & return & return

set contents of selection of front document to myHeader

set myFilePath to POSIX path of (path to home folder)
set myFilePath to myFilePath & "Documents/TKJournal/"
set {year:y, month:m, day:d} to (current date)
set myDateString to y * 1 & "-" & m * 1 & "-" & d * 1
set myFilePath to myFilePath & myDateString & "-" & mySelection & ".txt"
try
save front document in POSIX file myFilePath
end try
end tell
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s