Entrepreneurial Life

Pentadactyl - Executing bookmarks from the command line

Published 08 Dec 2011

Pentadactyl is an indispensable part of my workflow when using Firefox. It allows me to use VIM commands to control Firefox.

I use DevonThink Pro Office in conjunction with Firefox to capture information that I want to organize and refer to later.

DevonThink provides a bookmarklet that allows us to get information into DevonThink from Firefox quickly.

Normally, without Pentadactyl, you’d add the Clip to DevonThink bookmarklet to your browser and then subsequently click on it in the navigation toolbar anytime you wanted to invoke the clip functionality.

Since I use Pentadactyl almost exclusively to control Firefox, I want to execute the bookmarklet from the Pentadactyl command line.

Here is how to set this up (in Firefox):

:bmark -keyword clip "javascript:window.location='x-devonthink://clip?title='+encodeURIComponent(document.title)+'&location='+encodeURIComponent(window.location)+'&referrer='+encodeURIComponent(document.referrer)+'&width='+window.innerWidth+'&source='+encodeURIComponent(document.documentElement.outerHTML)+'&text='+encodeURIComponent(getSelection());"

I give the bookmark the keyword ‘clip’ as a mnemonic.

At this point you can execute the bookmark on your current URL by doing the following (in Firefox):

:open clip

or

o clip

I wanted to make that shorter though, so I created a Pentadactyl command to do the same:

:map -ex gC :open clip

This allows you to execute the clip to DevonThink bookmarklet via:

gC

I then write it to my Pentadactyl resource configuration file via:

:mkpentadactylrc!

The Pentadactyl resource configuration file is located in your user home directory.

Here is a discussion of the bookmark solution space that you might find useful.