Google Search, Google Site Search, Google News from the terminal
googler is a power tool to Google (Web & News) and Google Site Search from the command-line.
It shows the title, URL and abstract for each result, which can be directly opened in a browser from the terminal.
Results are fetched in pages (with page navigation). Supports sequential searches in a single
googler was initially written to cater to headless servers without X. You can integrate it with a text-based browser.
However, it has grown into a very handy and flexible utility that delivers much more.
For example, fetch any number of results or start anywhere, limit search by any duration,
define aliases to google search any number of websites, switch domains easily…
all of this in a very clean interface without ads or stray URLs.
The shell completion scripts make sure you don’t need to remember any options.
googler isn’t affiliated to Google in any way.
Table of contents
- Google Search, Google Site Search, Google News
- Fast and clean (no ads, stray URLs or clutter), custom color
- Navigate result pages from omniprompt, open URLs in browser
- Effortless keyword-based site search with googler @t add-on
- Fetch n results in a go, start at the nth result
- Disable automatic spelling correction and search exact keywords
- Specify duration, country/domain (default: worldwide/.com), language
- Google keywords (e.g.
- Open the first result directly in browser (as in I’m Feeling Lucky)
- Non-stop searches: fire new searches at omniprompt without exiting
- HTTPS proxy, User Agent, TLS 1.2 (default) support
- Man page with examples, completion scripts for Bash, Zsh and Fish
- Minimal dependencies
googler requires Python 3.3 or later. Only the latest patch release of each minor version is supported.
To download this repository, you may either clone via git:
$ git clone https://github.com/jarun/googler/
To install to the default location (
$ sudo make install
googler and associated docs, run
$ sudo make uninstall
PREFIX is supported, in case you want to install to a different location.
googler is a standalone executable. From the containing directory:
Shell completion scripts for Bash, Fish and Zsh can be found in respective subdirectories of
auto-completion/. Please refer to your shell’s manual for installation instructions.
googler v2.7 and later ships with an in-place self-upgrade mechanism which you may want to disable. To do this, run
$ make disable-self-upgrade
Googler is a single standalone script, so you could download just a single file if you’d like to.
To install the latest stable version, run
$ sudo curl -o /usr/local/bin/googler https://raw.githubusercontent.com/jarun/googler/v3.1/googler && sudo chmod +x /usr/local/bin/googler
You could then let googler upgrade itself by running
$ sudo googler -u
Similarly, if you want to install from git master (risky), run
$ sudo curl -o /usr/local/bin/googler https://raw.githubusercontent.com/jarun/googler/master/googler && sudo chmod +x /usr/local/bin/googler
and upgrade by running
$ sudo googler -u --include-git
usage: googler [-h] [-s N] [-n N] [-N] [-c TLD] [-l LANG] [-x] [-C] [--colors COLORS] [-j] [-t dN] [-w SITE] [-p PROXY] [--noua] [--notweak] [--json] [--show-browser-logs] [--np] [-u] [--include-git] [-v] [-d] [KEYWORD [KEYWORD ...]] Google from the command-line. positional arguments: KEYWORD search keywords optional arguments: -h, --help show this help message and exit -s N, --start N start at the Nth result -n N, --count N show N results (default 10) -N, --news show results from news section -c TLD, --tld TLD country-specific search with top-level domain .TLD, e.g., 'in' for India. Ref: https://en.wikipedia.org/wiki/List_of_Google_domains -l LANG, --lang LANG display in language LANG -x, --exact disable automatic spelling correction -C, --nocolor disable color output --colors COLORS set output colors (see man page for details) -j, --first, --lucky open the first result in web browser and exit -t dN, --time dN time limit search [h5 (5 hrs), d5 (5 days), w5 (5 weeks), m5 (5 months), y5 (5 years)] -w SITE, --site SITE search a site using Google -p PROXY, --proxy PROXY tunnel traffic through an HTTPS proxy (HOST:PORT) --noua disable user agent --notweak disable TCP optimizations and forced TLS 1.2 --json output in JSON format; implies --noprompt --show-browser-logs do not suppress browser output (stdout and stderr) --np, --noprompt search and exit, do not prompt -u, --upgrade perform in-place self-upgrade --include-git when used with --upgrade, upgrade to latest git master -v, --version show program's version number and exit -d, --debug enable debugging omniprompt keys: n, p fetch the next or previous set of search results index open the result corresponding to index in browser f jump to the first page o [index|range|a ...] open space-separated result indices, numeric ranges (sitelinks unsupported in ranges), or all, in browser open the current search in browser, if no arguments g keywords new Google search for 'keywords' with original options should be used to search omniprompt keys and indices q, ^D, double Enter exit googler ? show omniprompt help * other inputs issue a new search with original options
googler doesn’t have any! This is to retain the speed of the utility and avoid OS-specific differences. Users can enjoy the advantages of config files using aliases (with the exception of the color scheme, which can be additionally customized through an environment variable; see Colors). There’s no need to memorize options.
For example, the following alias for bash/zsh/ksh/etc.
alias g='googler -n 7 -c ru -l ru'
fetches 7 results from the Google Russia server, with preference towards results in Russian.
The alias serves both the purposes of using config files:
- Persistent settings: when the user invokes
g, it expands to the preferred settings.
- Override settings: thanks to the way Python
googleris written so that the settings in alias are completely overridden by any options passed from cli. So when the same user runs
g -l de -c de -n 12 hello world, 12 results are returned from the Google Germany server, with preference towards results in German.
googler @t is a convenient add-on to Google Site Search with unique keywords. While
googler has an integrated option to search a site, we simplified it further with aliases. The file googler_at contains a list of website search aliases. To source it, run:
$ source googler_at
$ . googler_at
googler @t, here’s how you search Wikipedia for
$ @w hexspeak
Oh yes! You can combine other
googler options too! To make life easier, you can also configure your shell to source the file when it starts.
All the aliases start with the
@ symbol (hence the name
googler @t) and there is minimum chance they will conflict with any shell commands. Feel free to add your own aliases to the file and contribute back the interesting ones.
googler works out of the box with several text-based browsers if the
BROWSER environment variable is set. For instance,
$ export BROWSER=w3m
or for one-time use,
$ BROWSER=w3m googler query
Due to certain graphical browsers spewing messages to the console,
googler suppresses browser output by default unless
BROWSER is set to one of the known text-based browsers: currently
w3m. If you use a different text-based browser, you will need to explicitly enable browser output with the
--show-browser-logs option. If you believe your browser is popular enough, please submit an issue or pull request and we will consider whitelisting it. See the man page for more details on
googler allows you to customize the color scheme via a six-letter string, reminiscent of BSD
LSCOLORS. The six letters represent the colors of
- metadata/publishing info (Google News only)
respectively. The six-letter string is passed in either as the argument to the
--colors option, or as the value of the environment variable
We offer the following colors/styles:
|A-H||bold version of the lowercase-letter color|
|I-P||bold version of the lowercase-letter bright color|
|Y||bold reverse video|
The default colors string is
GKlgxy, which stands for
- bold bright cyan indices
- bold bright green titles
- bright yellow URLs
- cyan metadata/publishing info
- normal abstracts
- reverse video prompts
- Bright colors (implemented as
\x1b[97m) may not be available in all color-capable terminal emulators;
- Some terminal emulators draw bold text in bright colors instead;
- Some terminal emulators only distinguish between bold and bright colors via a default-off switch.
Please consult the manual of your terminal emulator as well as the Wikipedia article on ANSI escape sequences.
- Google hello world:
$ googler hello world
- Fetch 15 results updated within the last 14 months, starting from the 3rd result for the keywords jungle book in site imdb.com:
$ googler -n 15 -s 3 -t m14 -w imdb.com jungle book
- Read recent news on gadgets:
$ googler -N gadgets
- Fetch results on IPL cricket from Google India server in English:
$ googler -c in -l en IPL cricket
- Search quoted text:
$ googler it\'s a \"beautiful world\" in spring
- Search for a specific file type:
$ googler instrumental filetype:mp3
- Disable automatic spelling correction, e.g. fetch results for
$ googler -x googler
- I’m feeling lucky search:
$ googler -j leather jackets
- Website specific search:
$ googler -w amazon.com -w ebay.com digital camera
Site specific search continues at omniprompt. Use the
g key to run a regular Google search. 10. Alias to find definitions of words:
alias define='googler -n 2 define'
- Look up
g keywordsor a result index at the omniprompt: As the omniprompt recognizes
gor index strings as commands, you need to prefix them with
g n g g keywords g 1
- Input and output redirection:
$ googler -C hello world < input > output
-Cis required to avoid printing control characters (for colored output).
- Pipe output:
$ googler -C hello world | tee output
- Use a custom color scheme, e.g., a warm color scheme designed for Solarized Dark (screenshot):
$ googler --colors bjdxxy google $ GOOGLER_COLORS=bjdxxy googler google
- Tunnel traffic through an HTTPS proxy, e.g., a local Privoxy instance listening on port 8118:
$ googler --proxy localhost:8118 google
By default the environment variable
https_proxyis used, if defined.
- More help:
$ googler -h $ man googler
- In some instances
googlermay show fewer number of results than you expect, e.g., if you fetch a single result (
-n 1) it may not show any results. The reason is Google shows some Google service (e.g. Youtube) results, map locations etc. depending on your geographical data, which
googlertries to omit. In some cases Google (the web-service) doesn’t show exactly 10 results (default) on a search. We chose to omit these results as far as possible. While this can be fixed, it would need more processing (and more time). You can just navigate forward to fetch the next set of results.
- By default
googlerapplies some TCP optimizations and forces TLS 1.2 (on Python 3.4 and above). If you are facing connection issues, try disabling both using the
- Initially I raised a pull request but I could see that the last change was made 7 years earlier. In addition, there is no GitHub activity from the original author Henri Hakkinen in past year. I have created this independent repo for the project with the name
googler. I retained the original copyright information.
- Google provides a search API which returns the results in JSON format. However, as per my understanding from the official docs, the API issues the queries against an existing instance of a custom search engine and is limited by 100 search queries per day for free. In addition, I have reservations in paying if they ever change their plan or restrict the API in other ways. So I refrained from coupling with Google plans & policies or exposing my trackable personal custom search API key and identifier for the public. I retained the browser-way of doing it by fetching html, which is a open and free specification.
- You can find a rofi script for
googlerhere. Written by an anonymous user, untested and we don’t maintain it.
22 total views, 1 views today