Custom search keywords

Thursday 26 May 2022

You can define custom search keywords in your browser to make common searches easier. How to do it isn’t well documented, so I’m showing you how here.

As an example, I have a custom keyword “pypi”, so I can search PyPI for a package name by typing “pypi some name” in my browser’s address bar, and it takes me directly to https://pypi.org/search/?q=some name.

You can create your own custom keywords to have shortcuts to all kinds of searches. You provide a URL with a placeholder %s in it. When you type the keyword in the address bar, the rest of the entry is plugged into the placeholder, and you jump to the resulting URL.

Handy keywords

These are some of the custom search keywords I use. You can use them as-is, adapt them as you need, or create your own. Instructions for creating keywords are further down the page.

py: Search Python docs
https://www.google.com/search?q=site%3Adocs.python.org%20%s
pep: Find a PEP by number
https://peps.python.org/pep-0%s
pypi: Find a PyPI package
https://pypi.org/search/?q=%s
gh: GitHub code search
https://github.com/search?type=Code&q=%s
gpy: Google search for Python things, but not Monty Python
http://www.google.com/search?q=%s+python+-monty
xlate: Translate text, auto-detecting the language
https://translate.google.com/?sl=auto&tl=en&op=translate&q=%s

How to define a keyword in Firefox

Firefox defines custom keywords as bookmarks:

  1. Select Bookmarks - Manage Bookmarks from the menu to open the Library dialog.
  2. In the left-hand sidebar, select Quick Searches. You’ll see a handful of pre-defined searches.
  3. Using the gear drop-down at the top of the dialog, select Add Bookmark...
  4. Enter the URL of the search in the URL field. Use %s as the placeholder.
  5. Put the keyword you want to use in the Keyword field.
  6. You can give the bookmark a name to make it easier to find it later if you need to.
  7. Save the bookmark, and close the Library.
  8. Now you can use your keyword in the address bar.

How to define a keyword in Chrome

Chrome defines custom keywords as search engines in Settings:

  1. Select Preferences or type chrome://settings in the address bar.
  2. In the left-hand sidebar, select Search engine and then Manage search engines and site search.
  3. Scroll down to Site search.
  4. Click Add.
  5. Put a description in the Search engine field.
  6. Enter the URL in the URL field, with %s as a placeholder.
  7. Put the keyword in the Shortcut field.
  8. Click Add, then close the Settings tab.
  9. Now you can use your keyword in the address bar.

Comments

[gravatar]

On some browsers you can also use %S (upper case) and it won’t url-encode the value. For example if you use https://www.reddit.com/r/%S, you will be able to use keyword python/top whereas it won’t work with %s.

Add a comment:

Ignore this:
Leave this empty:
Name is required. Either email or web are required. Email won't be displayed and I won't spam you. Your web site won't be indexed by search engines.
Don't put anything here:
Leave this empty:
Comment text is Markdown.