Wednesday, February 29, 2012

Quickly search code on GitHub with Chrome

You're looking at a project on GitHub, say Orbeon Forms, and would like to do a search in that project. GitHub provides a search field, but it searches through everything on GitHub, not just the current project you're looking at. This unless you click on the Advanced Search icon, in Search for select Code, and prefix your search by repo:orbeon/orbeon-forms. If you're anything like me, you'll find this too time consuming and won't use the GitHub site for searching.

Luckily, if you're using Chrome, there is a shortcut. With that "shortcut" in place, type o hello world in the location bar, and you'll see:


Press enter, and you'll get the results from GitHub. Now that is something I'd use! All you need to do:

  1. Go to the Chrome settings (⌘, on OS X).
  2. In the Search section (shown below), click on Manage Search Engines.


  3. Scroll to the very bottom of that dialog to add a new entry. In the first field enter a descriptive name, say Orbeon Forms source. In the second, the keyword you'll use as a prefix when doing a search, say o for Orbeon. (You can pick a more descriptive keyword, but I'm in a rush, so o it is.) Finally, the last field put:

    https://github.com/search?type=Code&q=repo%3Aorbeon%2Forbeon-forms+%s

    Note the orbeon%2Forbeon-forms in that URL, which you can change if you'd like to search another GitHub projects. With this, your new custom search engine will look like:

Enjoy!

1 comment:

  1. Thanks, this is IMO quicker and works for all repos: http://userscripts.org/scripts/show/137792

    ReplyDelete