Browser search engine shortcuts

You can add Sourcegraph as a browser search engine to quickly search Sourcegraph from your browser’s location bar when you type a special shortcut, such as src. This is one of the most common ways to initiate a search on Sourcegraph.


Adding Sourcegraph as a browser search engine

The easiest way is to install the Sourcegraph browser extension, which automatically configures the location bar src shortcut to search Sourcegraph.

Google Chrome

  1. Perform a code search on the Sourcegraph instance you want to add as a search engine.
  2. Copy the URL of the search results page.
  3. Go to chrome://settings. Under Search engine, click Manage search engines. Next to Other search engines, click ADD.
  4. In the Add search engine form, paste the URL you copied (in step 1) in the URL with %s in place of query field. Insert the string %s into the URL’s ?q= query parameter (and remove any parts of the query that you don’t want to keep).
  5. Fill in the keyword field with the keyboard shortcut you want for searching on Sourcegraph. In this example, it’s set to Tab.

5.Click ADD.

To use the shortcut, focus in the browser address bar, type in the keyword you chose (such as src), and press Space. Now type your Sourcegraph code search query and hit enter. You’ll be taken to the search results page on your Sourcegraph instance.

For more information on setting Chrome search engines, see Chrome’s help page.

Firefox

To add Sourcegraph as a search engine in Firefox:

  1. Visit any page on the Sourcegraph instance you want to add as a search engine.
  2. Click the magnifying glass icon in the toolbar’s search field.
  3. Click Add “Sourcegraph Search”.

To configure a shortcut (keyword) for quicker access:

  1. Click the magnifying glass icon in the toolbar’s search field.
  2. Click Change Search Settings.
  3. In the One-Click Search Engines list, double-click the Keyword cell for Sourcegraph Search and type in a shortcut (such as src).

To use the search engine, type src Space in the location bar, then your Sourcegraph search query. Pressing Enter will go to the Sourcegraph search results page for your query.

See “Add or remove a search engine in Firefox” for more information.

Other web browsers

Consult your web browser’s documentation or settings page for information on how to add custom search engines. Most web browsers support this feature.