edit DEVONthink records in terminal vim

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):

  1. Open Automator and select a new application.
    automator1
  2. From the Automator script library, first drag over the DEVONthink action Get Selected Records.
    automator2
  3. Next, drag over the DEVONthink action Get Item from Records.

    automator3

  4. 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.

    automator4

  5. 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
    

    automator5

  6. 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.

About

Associate Professor of Early Latin America Department of History University of Tennessee-Knoxville

Tagged with: , , , ,
Posted in Apps for Research, Research and Writing

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s

parecer:
parecer:

Hacer juicio ú dictamen acerca de alguna cosa... significando que el objeto excita el juicio ú dictamen en la persona que le hace.

Deducir ante el Juez la accion ú derecho que se tiene, ó las excepciones que excluyen la accion contrária.

RAE 1737 Academia autoridades
Buy my book!



Chad Black

About:
I, your humble contributor, am Chad Black. You can also find me on the web here.
%d bloggers like this: