• Home
  • Blog
  • Adding Dash support to Komodo IDE

Adding Dash support to Komodo IDE

Vincent Danen

February 24, 2016

I've recently found and become a fan of the Dash documentation browser for OS X. It has some neat integration with some applications, like Sublime Text and PyCharm (both of which I use), but not for Komodo IDE (which I also use). So this post is to show how easy it is to integrate the two.

Dash uses a URL scheme of

dash://[query]
that makes it really easy to tie into any application that can callout to such URLs. You can use URL scheme pretty much anywhere. For instance, if you wanted to search for "os.getpid" (a Python function) you could type:

$ open dash://python2:os.getpid

on the commandline in the Terminal and it will open Dash, searching in the Python docset, for this function. We will make use of that capability in our Komodo IDE toolbox.

The first step is to create a new toolbox item of the type "Command". The only things we need to do here is give it a name (like "dash lookup"), set the command to "open dash://%W" and check off the "Do not open output pane" (since there won't be any output). Finally, on the "Key Binding" tab, assign a new key binding; I chose CTRL-H since that mimics what Sublime Text uses.

komodo-toolbox

Now when your cursor is on a function or item in your Python code, or if you highlight something (this is represented by the "%W" in the command), hitting CTRL-H will open Dash and display search results.

If, however, you're like me, you probably have a lot of docsets installed in Dash and probably don't want to search all of them when you're working on your code. If you're working on Python, which is what I pretty much exclusively write code in, you wouldn't want search results for bash or git commands to show up.

Dash has this nice way of allowing you to restrict what docsets are searched based on what the former foreground application was (or the application that triggered the search). So in our case, we want to restrict what we search in Dash when we launch it from Komodo. When you click on the magnifying glass icon next to the search field in Dash, the following search profile editor pops up:

dash-search

In this case, I created a new search profile called "Komodo" and ensured that it's active only when Komodo becomes active. And then we can add which docsets to search. In this case, I only want to search the Flask, Jinja, and Python 2 docsets as well as the Python Format Strings cheatsheet. This allows me to search for things that are relevant to what I use Komodo for.

You can have as many search profiles as you like; you could define one for Sublime Text depending on what you use it for, you can define one for the Terminal (the aforementioned shell and git docsets would be a good candidate for searching from there), and so on.

As an aside, because I find this useful also, if you want to search for something in Dash from the commandline, you could create this script to do that:

$ cat ~/bin/dash

#!/bin/sh
if [ "${1}" == "" ]; then
    echo "I need an argument to launch dash with"
    exit
fi
open "dash://$@"

Dash pretty much just wants a single argument for the most part so something like:

$ dash "vagrant suspend"

only shows you search results for "vagrant". In this case you could type "vagrant:suspend" to have it search for the "suspend" command in the "vagrant" docset alone.

Dash is pretty neat and I'm enjoying using it as an easy reference tool. Using it has tidied up my browser window and I feel more productive with it and I really like how easy it is to summon it from almost any program that I'm using.

Leave a Comment

Comments use MarkDown. Need help? MarkDown Cheatsheet