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
Best Answer
Looks like the same question was asked for OSX.
w00t's solution of using a chrome extension with a global keyboard shortcut has the advantage of being OS-agnostic (and if I install it on Chrome on my windows machine I have it available on my Mac when I log in to my Chrome account).