You can run the following Terminal command (e.g. in a bash script):
open -a "Google Chrome" chrome://newtab
This will cause the application Google Chrome to open the URL chrome://newtab, thereby opening a new tab.
Unfortunately, Google Chrome doesn't register the chrome://
URL type with Launch Services, and it will think that's a file path.
To fix this, right-click Google Chrome's application bundle, select Show Package Contents, open the Contents directory and edit Info.plist
in a text editor.
Search for CFBundleURLTypes
. Edit the following few lines to add the lines indicated by a +
:
<key>CFBundleURLTypes</key>
<array>
+ <dict>
+ <key>CFBundleURLName</key>
+ <string>Chrome Internal URLs</string>
+ <key>CFBundleURLSchemes</key>
+ <array>
+ <string>chrome</string>
+ </array>
+ </dict>
<dict>
<key>CFBundleURLName</key>
<string>Web site URL</string>
Save and close. Move Google Chrome's application bundle to a different directory, and back again, to make Launch Services pick up the change (if it doesn't work, log out and back in).
Then, run open
like described at the beginning.
Once this works, your best option is to run a shell script that performs the open
command, which in turn is invoked e.g. by your launcher. Since I believe the delay is caused by osascript
loading, pretty much any solution you choose here should be fast enough.
To semi-automate the editing of the Info.plist
file (you have to repeat this for all Chrome updates), you can use PlistBuddy
in Terminal. First, create a file e.g. named chrome-url.plist
with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>CFBundleURLName</key>
<string>Chrome Internal URLs</string>
<key>CFBundleURLSchemes</key>
<array>
<string>chrome</string>
</array>
</dict>
</array>
</plist>
Then, you can use the following to patch Chrome's Info.plist
:
/usr/libexec/PlistBuddy -c "Merge '/path/to/chrome-url.plist' :CFBundleURLTypes" /Applications/Google\ Chrome.app/Contents/Info.plist
It looks like I've found a solution.
This blog post from August 26, 2011 describes how to open the next tab using the built-in browser tools.
Here is a quote from there (with small edits):
- Go to Chrome's Options / Preferences screen (click the wrench icon on the browser toolbar then select Options or Preferences -- whichever appears on your system).
- You'll find yourself in the "Basics" preference page, which should have a "Search" section. Click on the Manage Search Engines... button.
- You'll see a list of your custom-built search engines for various sites (if curious, read about Chrome's search engine configuration). At the bottom of the screen, find the set of empty fields for adding a new search engine.
- In the first field (labelled "Add a new search engine"), enter
Open new tab
or something similar. The words you choose are not important -- make them meaningful to you so they'll trigger your memory if you go back into this screen any time in the future.
- In the second field (labelled "Keyword"), enter a single word or single letter or a sequence of letters (no spaces nor punctuation). You'll be typing this every time you want to open a new tab to the immediate right, so short and memorable is good. I use
tt
- In the third field (labelled "URL with %s in place of query"), enter exactly this text including the semi-colon at the end:
javascript:window.open();
- Click anywhere outside the fields to "save" your entry.
That's the end of the set up. Now whenever you want to open a new tab next to your current tab, you can do this:
- Move the keyboard focus to the address bar (Ctrl-L or Cmd-L).
- The entire current address should be highlighted, but if not, highlight it all (Ctrl-A or Cmd-A).
- Type the keyword you chose in step 5 above -- e.g.,
tt
then Space (or Tab) and hit Enter or Return.
Once you get used to doing this, you'll be able to do it very quickly:
Cmd-L tt
Space (or Tab) Enter
The new tab will open immediately to the right of your current tab. Your current tab will not be affected except that the URL might have disappeared from the address bar; if you want to see the URL again, just reload the page (or press Esc).
There is also a comment there telling how to do it using the bookmark:
You can use the same technique to add a button in the Bookmarks Bar.
- Open Bookmark Manager.
- Select the Bookmarks Bars folder
- Select Organize > Add Page.
- Name the new page "New Tab" or something similar.
- In the URL field, add the javascript mentioned in the above post:
javascript:window.open();
You should now have a clickable button to open a new tab.
From myself I will add that if the first parameter in window.open()
is a link to the search engine with the pattern %s
, then you can perform a search at the same time as opening a new tab.
Here is my example:
javascript:window.open('https://www.google.com/search?q=%s');
Here is the sequence of actions to use this feature:
Cmd-L tt
Space (or Tab) Search query
Enter
Best Answer
It looks like it's a bug in the new release, check out this issue.