How to quickly add a file from terminal to devonthink


I often take quick notes using vim or any other editor and I would like to easily dump this note to devonthink so that I can manage it later.
At best it would be that this file is moved to devonthink not just copied and it would be nice if the interaction does not involve any mouse movements :wink:

Where are you saving the files too?

Using open with a proper build x-devonthink URL in the terminal might do the trick (if you put that in a shell script or something like it). Check out the section on “URL Commands” in the “Automation” section of the handbook.

For example, this

open "x-devonthink://createRTF?title=New%20bookmark&"

in Terminal will create a new RTF document in DT with the content of “

1 Like

When I do that, I save to the DEVONthink “global inbox” folder. What that is and how installed is discussed in the “DEVONthink Manual”

1 Like

hm this looks something I can try out.
In fact it would be event better to have a small vim plugin where the current buffer can be saved as a file to devonthink…
I will have a look if this is somehow possible

I have actually played around with this in the past.

As @rmschne mentioned DT3 provides an Inbox that sits in the filesystem and is monitored for new files. Once a file is in there it gets moved (as in mv) into the Global Inbox.

Hence you cannot have any file persist in the Inbox.

So if you save a vim buffer there without exiting the window, the file will disappear and vim will warn you that the file does not exist. Your buffer will remain intact, so you can actually write to that location again. It will just create a new file (and you will have multiple instances in DT3).

So it’s far better to script to write to file, close file and !mv to the Inbox, if that is what you want to achieve.

I just map a shell env variable (e.g. $INBOX) to that location so I can quickly move files in there from the terminal (or within vim).

The location of the Inbox is ~/Library/Application Support/Devonthink 3/Inbox/.


That is true. I forgot to mention that in this situation I would keep DEVONthink “off” and not running to avoid this issue.

Or … save to, say ~/Desktop then “mv” or Finder drag and drop into Inbox or direct to DEVONthink.

Or … save to a folder indexed to DEVONthink.

Or … (what frankly I do most the time) simply work on the files inside of DEVONthink and focus on the file not managing it.


There is another way if you are willing to use DT3 to “Index” a directory.

  1. You make a new directory anywhere in the file system (ie can be on an iCloud folder as well), or can be an existing directory.

  2. In the DT3 database of your choice select File > Index Files and Folders... and choose that directory.

Now you can write your vim buffer to a file in that directory and you should see changes reflected in DT3. And in fact, you can move in the opposite direction as well - changes you make from within DT3 on an indexed file will show up on your vim buffer but you will be warned of noeol (no a big deal).

I don’t use this method because there are so many moving and asynchronous parts. And I have suffered from duplicated files in the past due to file version collisions. If you are willing to deal with these issues then this could be a viable workflow.

You can read more about indexed files in DT3 in the Help section.

I was thinking about this approach as well (though I definitely am not a vim user). But in my testing, yes it appears to be potentially problematic.

Yes, it gets worse if you also sync that database where the indexed folder is to another instance of DT3 or DTTG.

1 Like