Tweet from the Chrome Address Bar by adding a Custom Search Engine

TIL: Chrome allows you to define a Custom Search Engine (CSE) by which you can search sites. The cool part is that you’re not really limited to search only, and that you can abuse these CSEs to become more productive. In this post I’ll show you how to tweet from the Chrome Address Bar.

🦊 Firefox User? You can achieve the same result by adding a bookmark.

~

TIL: Custom Search Engine

The idea was sparked by this tweet by Rowan Merewood. Rowan created a CSE to quickly go to a Zoom meeting by simply typing zoom meeting-id in the Chrome Address Bar.


Don’t mind the word “Search”: Upon hitting ENTER the browser won’t search Zoom but will directly go to the Zoom meeting with ID 123456789.

A Custom Search Engine (CSE) is defined by three parameters:

  • Search Engine: The name that will be shown in the Chrome Address Bar when typing in keyword
  • Keyword: The keyword that needs to trigger the Search Engine
  • URL: The URL that will be visited once you press enter. Use %s where you want your “search term” to appear.

Here’s how Rowan has define his Zoom CSE:

~

DuckDuckGo’s !tw command

Earlier today I saw Šime Vidas tweet about using DuckDuckGo’s !tw command interpretation to quickly compose a new tweet.

As he uses DuckDuckGo as his default search engine, the trick works fine from the address bar:

  1. The Address Bar will pass the entered term to search DuckDuckGo
  2. DuckDuckGo will interpret the !tw prefix and redirect to Twitter’s Compose Dialog

For users like me, who don’t use DuckDuckGo as their search engine, that won’t work.

~

1 + 1 = 2

Combining both ideas, I came to create a Custom Search Engine for Chrome that will allow me to quickly tweet from the Address Bar:

I’ve define a CSE so that the tw keyword will directly go to Twitter’s Compose Dialog. To define this CSE yourself, go to chrome://settings/searchEngines and add a new CSE with the following details:

  • Search Engine: Compose Tweet
  • Keyword: tw
  • URL: https://twitter.com/compose/tweet?text=%s

From now on you can compose a tweet by simply typing tw This is a tweet in the Chrome Address Bar.

Combine that with CMD+L, just like Šime did, and you can quickly tweet out links:

  1. Visit URL
  2. Hit CMD+L to focus the Address Bar
  3. Hit CMD+← to put the cursor before the URL
  4. Type in tw (with space) and hit enter

Cool!

~

Call to developers

I see lots of uses for this. You could create these kind of productivity shortcuts to go quickly to Twitter profile pages, visit NPM packages, auto-archive URLS on The Wayback Machine, etc. (Ab)using CSEs like this once again underlines the importance of bookmarkable URLs and the ability to precompose data along with that.

Do note that many sites (such as the mentioned Twitter, GitHub, NPMJS, etc.) already provide CSEs to actually search them. Same goes for WordPress blogs, such as this one right here: simply enter bram.us searchterm in the Chrome Address Bar and after hitting ENTER it’ll search this blog for the given searchterm.

~

Did this help you out? Like what you see?
Thank me with a coffee.

I don\'t do this for profit but a small one-time donation would surely put a smile on my face. Thanks!

BuymeaCoffee (€3)

To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Unless noted otherwise, the contents of this post are licensed under the Creative Commons Attribution 4.0 License and code samples are licensed under the MIT License

Join the Conversation

1 Comment

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.