I’m in the midst of planning my Fall seminar, which happens to be a course titled “Digital History in Theory and Practice.” Given the large number of online resources I’m using in the process, I’ve been drawn back to DEVONthink, which it’s nice Chrome plugin for saving pdf or webarchive records straight from the browser.
I’m doing a lot of reading as well, and taking notes. It’s been a while since I spent a lot of time in DEVONthink, and in the interim I’ve been completely converted to vim and markdown. I very much like taking notes in vim, leveraging the pandoc vim plugin and its tab completion of bibtex citations. The thing is, for some reason I much prefer vim in the terminal to MacVim. I don’t know exactly why, though I suspect its because vim in the terminal is much more integrated into the programming workflow I’ve been using the past year.
It’s very easy to open a DEVONthink record in an external editor. I take all my notes in DEVONthink as plain text notes, part of a commitment I made a couple of years ago to using plain text whenever possible. MacVim is the default editor for .txt
files on my machine. In DEVONthink, you can open any file in your database with the system default application either by clicking a toolbar icon or using the keyboard shortcut SHIFT-CMD-O
. But, what about terminal vim? A little more complicated.
So, I cobbled together a Automator application from posts here, here, and here that opens a highlighted record from DEVONthink in vim in a new tab in the terminal.
For my own documentation, and maybe to help you out, here’s how it works (click on the images to make them larger):
- Open Automator and select a new application.
-
From the Automator script library, first drag over the DEVONthink action
Get Selected Records
.
-
Next, drag over the DEVONthink action
Get Item from Records.
-
Go to this page and down load the file
Get File Path
, which is an Automator action to get the full file path of any file.Once you file is downloaded, double click on it to install it in your Automator library. Then, drag into fourth place on the workflow.
-
Now it’s time from some Applescript. Once we have the file path, we pipe it to a script that opens a new terminal tab, and then opens the file in vim. So, drag a
Run Applescript
action to the workflow and enter this code:on run {input} set the_path to POSIX path of input set cmd to "vim " & quoted form of the_path tell application "Terminal" activate end tell tell application "System Events" to tell process "Terminal" to keystroke "t" using command down tell application "Terminal" delay 0.25 do script with command cmd in front window end tell end run
-
Save the file in
~/Library/Application Support/DEVONthink Pro 2/Scripts
. Name it something that makes sense, like OpenInVim.
That’s it. Now, you can select that from the scripts icon off the topbar. Or better yet, set an application-specific keyboard shortcut, which you can do in the Keyboard
section of the System Preferences
. I set mine to OPTION-CMD-o
, so as not to clash with DT’s open-in-external-application shortcut.
Leave a Reply