From e16120f04122816ce887ee786c16a0b8be7008a4 Mon Sep 17 00:00:00 2001 From: Debian Live user Date: Sat, 29 Apr 2023 16:31:48 -0400 Subject: google: pass through options to w3m; and allow launching firefox --- dot/local/bin/google | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/dot/local/bin/google b/dot/local/bin/google index 94ebf0f..21c9feb 100755 --- a/dot/local/bin/google +++ b/dot/local/bin/google @@ -1,9 +1,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}) { exec qw(w3m), "$url" } -else { exec qw(w3m -o), "user_agent=$useragent", "$url" } +if (!$ENV{NO_FAKE_UA}) { + push @w3m, qw(-o), "user_agent=$useragent"; +} + +exec @w3m, $url; -- cgit v1.2.3