Created
April 14, 2011 23:09
-
-
Save gruber/920794 to your computer and use it in GitHub Desktop.
Perl script that can be used to create a system-wide service to do a Google web search. Input is the selected text in whatever the current app is. The result is a new Google query using your default web browser. (Mac OS X's built-in Search Google service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use strict; | |
use warnings; | |
use URI::Escape qw(uri_escape_utf8); | |
use open IO => ":utf8", # UTF8 by default | |
":std"; # Apply to STDIN/STDOUT/STDERR | |
my $query = do { local $/; <> }; | |
$query =~ s/^\s+//g; | |
$query =~ s/\s+$//g; | |
my $url = "http://www.google.com/search?&q=" . uri_escape_utf8($query); | |
system("/usr/bin/open", $url); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment