Log TaskPaper archives to Day One
I wrote a while back about some Day One geekery, and shared the git wrapper I set up for bagging some of my larger commit messages to Day One entries automatically. Then Rob went and asked me if I could do something similar with TaskPaper, logging archived tasks to Day One on the fly. Had to try it.
I built the script using the newer query syntax, and I find it a little more stable than the old project-by-project parsing method (nice work, Jesse). To use it, you just need a TaskPaper document with at least one project and an “Archive:” section, and Day One with the CLI tool installed.
- Using the frontmost document in TaskPaper, it grabs all the @done tasks1 (with or without a date) that aren’t already in the “Archive” project for processing.
- It goes through a few of my common “in-process” tags (@na, @priority, @waiting) and removes them if they exist on a @done task (they’re meaningless after completion).
- Then it looks to see if there’s a @project tag, and if not, it adds one for the project the task was in when it was archived (I think this is default TaskPaper behavior…).
- The full text content of each task (complete with Markdown-style list delimiter and all of the project/date tags you’d want in a log entry) is added to a string.
- Each @done task is then moved to the “Archive” project.
- The name of the parent file and the list of all the tasks you just archived are sent as a single entry to Day One using the
dayone
CLI tool.
I’m not certain that the end results of using this are superior to logging commit messages. With commit messages I’m talking about what I just did and noting any issues; just being more verbose in general. This technique is a really convenient way to log, though, if you’re already a TaskPaper (and Day One) user, and works perfectly as a supplement to other logging methods.
As you archive your tasks, they get dropped into a calendar view in ready-to-display Markdown format. It’s faster and prettier than to trying to maintain and sort archives of finished tasks in TaskPaper. Given that this is pretty much automatic in my current workflow, I’m just going to let both logging systems churn for a while and see if one or the other isn’t pulling its weight.
The script is thoroughly commented. Probably unnecessarily so for such a short task (I’m pretty sure there’s more comment than code in there). See below for brief installation instructions.
set archivedTasks to ""
tell application "TaskPaper"
tell front document
-- don't care which file your log entry came from?
-- comment the next line out
set archivedTasks to "## " & name & return
repeat with _task in search with query "project != Archive and @done"
if entry type of _task is not project type then
-- remove common tags that won't matter after archiving
repeat with _tag in {"na", "next", "priority", "waiting"}
if exists (tag named _tag of _task) then delete tag named _tag of _task
end repeat
-- if there's no project tag on the task,
-- add the task's current project as a tag
if not (exists (tag named "project" of _task)) then
tell _task to make tag with properties {name:"project", value:(name of containing project of _task as rich text)}
end if
-- append the full text of the entry, including tags, to our log
set archivedTasks to archivedTasks & (text line of _task)
-- archive it
move entry id (id of _task) to beginning of entries of project "Archive"
end if
end repeat
end tell
end tell
-- send the accumulated results to Day One via the command line tool
-- http://dayoneapp.com/faq/#commandlineinterface
-- You'll need to run `ln -s "/Applications/Day One/Day One.app/Contents/MacOS/dayone" /usr/local/bin/dayone` to have it accessible at this path
do shell script "echo " & (quoted form of archivedTasks) & "|tr -d \"\\t\"|/usr/local/bin/dayone new"
Just copy the script into AppleScript Editor and save it as a compiled script in ~/Library/Scripts/Applications/TaskPaper
(creating the folder if it’s not there). If you have the AppleScript menubar item enabled in AppleScript Editor preferences, you’ll be able to access the script from within TaskPaper. It’s really only convenient if you have a hotkey, though. Keyboard Maestro, FastScripts, Launchbar, System Preferences… whatever your poison, just make it easy.
Again, you’ll need to have the dayone
CLI tool linked to /usr/local/bin/dayone
(or modify the path in the script). If you have Day One installed in the standard /Applications directory, just run this in Terminal:
ln -s "/Applications/Day One/Day One.app/Contents/MacOS/dayone" /usr/local/bin/dayone
Thanks for the idea, Rob!
Update 2015-01-18: There’s a revision of this script available from Phil Jackson. It allows the inclusion of notes along with each task logged. Note that it uses jrnl instead of the dayone CLI.
-
D, but you knew that. ↩