Skip to main content

How To Google Search From Commandline Using Googler

Googler features

  • Google Search, Google Site Search, Google News, Google Videos.
  • Fast and clean interface with no ads or stray URLs.
  • Each search result can be opened from the omniprompt (i.e. the googler prompt), without re-running googler every time. Meaning – you can perform new searches without leaving googlr.
  • Open URLs in the default browser.
  • Integrate Googler in your Text-browser.
  • Open the first search result directly in the browser (as in “I’m feeling lucky” feature).
  • Fetch any number of results and the start at nth result.
  • Supports Google search keywords (Eg. site:ostechnix.com, filetype:pdf).
  • Safe search support (i.e. excluding adult sites).
  • HTTPS proxy, User Agent, TLS 1.2 (default) support.
  • Filter search results by duration, domain, country and language.
  • Switch from one Domain to another easily.
  • Define aliases to google search any number of websites.
  • You can disable automatic spelling correction to search for exact search terms.
  • Lightweight and requires minimal dependencies.
  • Free and open source!!


Install Googler On Linux

Googler can be installed in multiple ways. Make sure you have installed Python 3.5 or later. And xsel or xclip or termux-clipboard-set to copy URL into the clipboard. These packages are mostly comes pre-installed. Just in case if they are not installed already,, you can install them using your distribution’s package manager. For example on Debian and Ubuntu, the prerequisites can be installed using command:
$ sudo apt-get install python3.5 xsel xclip

1. Install latest Googler standalone version

This is the easiest and recommended way to install Googler on Unix-like operating systems.
Download the latest available Googler version:
$ sudo curl -o /usr/local/bin/googler https://raw.githubusercontent.com/jarun/googler/v4.0/googler
Make it executable:
$ sudo chmod +x /usr/local/bin/googler
Done!
You can update to the latest version at any time using command:
$ sudo googler -u. 

Basic Google Search using Googler

Open your Terminal and type “googler” followed by your search term.
For example, let me search for the term – “ostechnix“.
$ googler ostechnix
You will get results related to “ostechnix” keyword.
OPEN WEB PAGES IN BROWSER
As you can see in the above output, I got six results and each result has an index number (or prefix number). Just type the number and hit ENTER to open the respective page in your default web browser. For example, if you type number 3, the third page from the result will open in the browser. It is that simple!
NAVIGATE THROUGH SEARCH RESULTS
To go to the next set of search results, simply press the letter n. Similarly, you can go to previous set of results by pressing p. Memorize it like – n for next and p for previous. To go the first page of google search results instantly from any page, press f.
SEARCHING FOR NEW KEYWORDS
To search for a new keyword, you don’t have to exit and re-run googler. We can perform non-stop searches without exiting Googler. Just type the new keyword in the omniprompt (i.e. googler prompt) and hit ENTER.
search for new keyword googler
As you can see, I am searching for a new keyword – linux.
COPY URLS TO CLIPBOARD
We can copy a specific URL from the result to clipboard by pressing the letter c followed by the index number of the respective URL. Please mind the space between ‘c’ and the index number.
Example:
googler (? for help) c 3
Here, we use c for copy and 3 is the index number. Hence the third page from the search results will be copied to clipboard. Please remember – you must have installed any one of the following utilities to use this feature.
  • xclip
  • xsel
  • termux-clipboard-set

Exit Googler

To exit from Googler and return back to Terminal,
  • press q and hit ENTER,
  • or press ENTER twice,
  • or press Ctrl+d.
These search tips are just enough in most cases. If you’d like to some advanced google search tips, read on.

Some advanced Google search tips

Googler supports all google keyword functionalities to get exact and precise results quickly and easily. Here I have included some of advanced Google search tips that I use from time to time.
FILTER RESULTS BY WEBSITE (SITE-SPECIFIC SEARCH)
The following command will get you the results for the search term arch linux from www.ostechnix.com blog only.
$ googler arch linux site:ostechnix.com
Or,
$ googler arch linux -w ostechnix.com
search on specific website using googler
See? I am getting the results only from ostechnix.com site.
LIST SIMILAR WEBSITES
This can be useful when you want to find all similar sites that shares a common niche.
$ googler related:www.ostechnix.com
SEARCH FOR QUOTED TEXT
At times you might want to search for some exact texts, for example song lyrics or quotes of a famous author. If so, just mention them inside quotes like below.
$ googler "You have to dream before the dream comes true"
SEARCH FOR SPECIFIC FILE TYPE
This tip will be useful when searching for a specific type of a file to download, for example a song, video, movie or text or pdf file.
$ googler blockchain filetype:pdf
The above command will fetch results related to Blockchain documents in pdf format.
FIND DEFINITIONS OF WORDS
Want to learn the definition of a word (Eg. acumen) from various online resources? Here you go!
$ googler define acumen
FETCH SPECIFIC NUMBER OF RESULTS
By default, Googler will display 10 results. You can change this behaviour using n flag like below. The following command will only fetch 3 resultsfor the given search query.
$ googler -n 3 ostechnix
Fetch specific number of results using googler
DISPLAY RESULTS STARTING FROM NTHRESULT
The following example will fetch the results starting from the 5th result for the keyword ostechnix:
$ googler -s 5 ostechnix
DISPLAY RESULTS WITHIN A SPECIFIC TIME SPAN
Fetch 10 results updated within the last 5 months, starting from the 3rd result for the keyword linux in ostechnix.com site:
$ googler -n 10 -s 3 -t m5 -w ostechnix.com linux
FETCH RESULTS FROM GOOGLE NEWS SECTION
The following command will fetch results related to “Arch linux” from news.google.com section.
$ googler -N Arch linux
FETCH COUNTRY-SPECIFIC RESULTS
You might have noticed that when you search something on google, you will get the results based on the country where you live. For example if you live in India, you will get results from Google India server.
If you want Googler to fetch search results exclusively from a certain country or region, use -c flag.
$ googler -c in best smartphone
This will return results from Google India server for best smartphone query.
FETCH LANGUAGE-SPECIFIC RESULTS
Like country-specific results, we can return language-specific results using -l flag.
$ googler -l ta arthashastra
This command will fetch results related to arthashatra including Tamil web pages.
DISABLE AUTOMATIC SPELLING CORRECTION
When we search specific terms, the Google will display the spelling suggestions (starting with a message Did you mean..), especially for technical and medical related search terms. If you want to disable this spell check feature, use -x flag.
$ googler -x googler
I’M FEELING LUCKY SEARCH
As you already know, the Google’s homepage includes a button labeled “I’m Feeling Lucky” below the search bar. When we type a search query and click this button, we will be taken directly to the first search result, bypassing the search engine results page.
Googler has an option to do this from command line. To perform “I’m Feeling Lucky” search, use -j flag followed by your search term as shown below.
$ googler -j browse web with vim keybindings
DISPLAY SITE INFORMATION
To get the information of a website/blog, run:
$ googler info:www.ostechnix.com
EXCLUDE ADULT WEBSITES FROM THE SEARCH RESULTS
To search for “sex education” material without returning adult sites, use:
$ googler safesearch:sex education
FETCH SEARCH RESULTS THAT CONTAINS A SPECIFIC TERM IN THE PAGE TITLE OR URL
$ googler allintitle:linux -w ostechnix.com
This will return all results that contains the word linux in the title from ostechnix.com.
Similarly, we can limit the results to those with all of the query words in the URL.
$ googler allinurl:linux -w ostechnix.com
PIPE SEARCH RESULTS TO A FILE
It is one of my favorite Google search tip. I have a habit of saving the results along with URLs in a text file when searching for a specific topic. This way I can refer the results later. To me, It is kind of offline bookmarking!
$ googler -C python | tee tutorial.txt
The above command will search for Python and save all the search results in a text file called tutorial.txt in the current working directory.

Simplify Google search with aliases

This feature is for the lazy users! Googler offers many website search aliases for many popular websites including Amazon, Arch Linux wiki, BBC, CNN, eBay, Facebook, Google search, GitHub, HackerNews, IMDB, LinkedIn, National Geographic, MIT OpenCourseWare, Python documentation, Quora, Reddit, Stack Overflow, Twitter, Ubuntu forums, Wikipedia and a lot more.
For example, to search something on Arch Wiki, simply run:
$ @aw install arch linux
Here, @aw is the alias for ArchWiki site. “install arch linux” is the keyword.
To enable this feature, download the googler @t add on and enable it like below.
$ wget https://raw.githubusercontent.com/jarun/googler/master/auto-completion/googler_at/googler_at
$ source googler_at
You can also add your own aliases. For example, I have created an alias named @ostech for ostechnix.com blog.
$ alias @ostech='googler -w ostechnix.com'
To search from ostechnix.com, I simply run:
$ @ostech dns
Add your aliases to ~/.bashrc file to make it permanent.
Refer the following guide to learn to use aliases in Linux.

Comments

Popular posts from this blog

4 Ways to Communicate Across Browser Tabs in Realtime

1. Local Storage Events You might have already used LocalStorage, which is accessible across Tabs within the same application origin. But do you know that it also supports events? You can use this feature to communicate across Browser Tabs, where other Tabs will receive the event once the storage is updated. For example, let’s say in one Tab, we execute the following JavaScript code. window.localStorage.setItem("loggedIn", "true"); The other Tabs which listen to the event will receive it, as shown below. window.addEventListener('storage', (event) => { if (event.storageArea != localStorage) return; if (event.key === 'loggedIn') { // Do something with event.newValue } }); 2. Broadcast Channel API The Broadcast Channel API allows communication between Tabs, Windows, Frames, Iframes, and  Web Workers . One Tab can create and post to a channel as follows. const channel = new BroadcastChannel('app-data'); channel.postMessage(data); And oth...

Certbot SSL configuration in ubuntu

  Introduction Let’s Encrypt is a Certificate Authority (CA) that provides an easy way to obtain and install free  TLS/SSL certificates , thereby enabling encrypted HTTPS on web servers. It simplifies the process by providing a software client, Certbot, that attempts to automate most (if not all) of the required steps. Currently, the entire process of obtaining and installing a certificate is fully automated on both Apache and Nginx. In this tutorial, you will use Certbot to obtain a free SSL certificate for Apache on Ubuntu 18.04 and set up your certificate to renew automatically. This tutorial will use a separate Apache virtual host file instead of the default configuration file.  We recommend  creating new Apache virtual host files for each domain because it helps to avoid common mistakes and maintains the default files as a fallback configuration. Prerequisites To follow this tutorial, you will need: One Ubuntu 18.04 server set up by following this  initial ...

Working with Node.js streams

  Introduction Streams are one of the major features that most Node.js applications rely on, especially when handling HTTP requests, reading/writing files, and making socket communications. Streams are very predictable since we can always expect data, error, and end events when using streams. This article will teach Node developers how to use streams to efficiently handle large amounts of data. This is a typical real-world challenge faced by Node developers when they have to deal with a large data source, and it may not be feasible to process this data all at once. This article will cover the following topics: Types of streams When to adopt Node.js streams Batching Composing streams in Node.js Transforming data with transform streams Piping streams Error handling Node.js streams Types of streams The following are four main types of streams in Node.js: Readable streams: The readable stream is responsible for reading data from a source file Writable streams: The writable stream is re...