Macos – Shortcut to open new tab with selected text in Chrome

google-chromekeyboard shortcutsmacostabbed-browsing

I need this shortcut when some website display link in plain text, or I wanna google some words in the page.

Right-clicking the menu can do this; but I'd like only use the keyboard which is much more effective.

Now I use Cmd-C, Cmd-T, Cmd-V, Enter to do this.

Best Answer

There's a built-in service that opens a selected text URL in a default application. It requires the URL to have a scheme though and doesn't fall back to a Google search or anything.


You could also create a custom service that opens a URL or a Google search page:

input="$(cat)"
input="${input%\n}" # remove a possible trailing newline
if [[ "$input" =~ '://' ]]; then
    open "$input"
else
    open "http://www.google.com/search?q=$(echo -En "$input" |
    ruby -e 'require "cgi"; print CGI.escape($<.read.chomp)')"
fi