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
With the Sourcegraph browser extension (recommended)
The easiest way is to install the Sourcegraph browser extension, which automatically configures the location bar src shortcut to search Sourcegraph.
- Perform a code search on the Sourcegraph instance you want to add as a search engine.
- Copy the URL of the search results page.
- Go to
chrome://settings. Under Search engine, click Manage search engines. Next to Other search engines, click ADD.
- 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
%sinto the URL’s
?q=query parameter (and remove any parts of the query that you don’t want to keep).
- Fill in the keyword field with the keyboard shortcut you want for searching on Sourcegraph. In this example, it’s set to s.
To use the shortcut, focus in the browser address bar, type in the keyword you chose (such as src), and press Tab. 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.
To add Sourcegraph as a search engine in Firefox:
- Visit https://sourcegraph.com/search (or your own Sourcegraph instance)
- Click the three dots in the URL bar and choose Add Search Engine:
- You may then search using your URL bar and select
Sourcegraphfrom the list of search engines:
To configure a shortcut (keyword) for quicker access:
- In the URL bar, enter about:preferences#search
- Scroll down to One-Click Search Engines, double-click the Keyword cell for Sourcegraph and type in a shortcut (such as src).
To use the search engine, type src Tab in the URL bar, then type your Sourcegraph search query. Pressing Enter will then go right to Sourcegraph!
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.