summaryrefslogtreecommitdiff
path: root/dot/local/bin/google
blob: 21c9feb7dcda29358220c06240d08e71a4abd3c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl -w
$useragent = 'User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:64.0) Gecko/20100101 Firefox/64.0';

my @w3m = qw(w3m);
while ($ARGV[0] =~ m/^-/)
{
  if ($ARGV[0] eq '--') {
    shift;
    last;
  } elsif ($ARGV[0] eq '--firefox') {
    shift;
    $w3m[0] = 'firefox';
  } else {
    push @w3m, shift();
  }
}

$_ = join ' ', map { m/ / ? qq<"$_"> : $_ } @ARGV;
s/([^a-zA-Z0-9])/sprintf "%%%x", ord $1/ge;
$url = "https://www.google.com/search?q=$_";

if (!$ENV{NO_FAKE_UA}) {
  push @w3m, qw(-o), "user_agent=$useragent";
}

exec @w3m, $url;