How To Google Search From Commandline Using Googler
Google Search is the top most used search engine on the Web. Compared to other search engines, such as Baidu, DuckDuckGo and Yandex etc., Google search still holds the position of most popular search engine, with more than 70% of the search market share. Google search has become part of our lives, both personally and professionally. We all do know how to search on Google anything and everything from a Web browser. In this guide, we will see how to do Google search from commandline. Say hello to Googler, a command line tool to search on Google right from the Terminal on Linux and Unix.
Googler shows the title, URL and abstract for each result in a clean interface, without ads or stray URLs. Each result have an index number and you can open them in your default web browser by pressing the respective number. It was originally developed for headless servers that has no GUI. It has now become more convenient, flexible and mature tool packed with lots of features. Since it It comes with auto-completion feature, you don’t have to remember any options! Additionally, you can bring up the help section by simply pressing the ? (question mark).
- 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
You can update to the latest version at any time using command:
$ sudo googler -u
2. Install Googler from source
Make sure you have installed development tools on your Linux box and install Googler by running the following commands one by one.
$ git clone https://github.com/jarun/googler.git
$ cd googler/
$ sudo make install
$ cd auto-completion/bash/
$ sudo cp googler-completion.bash /etc/bash_completion.d/
3. Using Package manager
Googler has been packaged for many popular Linux distributions. If you want a stable version, you can install Googler from your distribution’s repositories.
$ yay -S googler
On Debian, Ubuntu, Linux Mint and other DEB-based systems:
$ sudo apt-get install googler
$ sudo dnf install googler
On CentOS 8:
$ sudo dnf install epel-release
$ sudo dnf install googler
On openSUSE Leap/Tumbleweed:
$ sudo zypper install googler
The googler version in the distribution’s repositories might be bit old and doesn’t has new features. If you want to try most recent version, install googler standalone script as described in the first method or install from source as shown in the second method.
4. Download and Install binary packages
Googler is also available as binary packages for various Linux distributions. Just download the latest version from the releases page and install it using your distribution’s package manager. Please note that you must have installed all required perquisites.
For example, on DEB-based systems, you can install Googler like below.
$ wget https://github.com/jarun/googler/releases/download/v4.0/googler_4.0-1_ubuntu18.04.amd64.deb
$ sudo dpkg -i googler_4.0-1_ubuntu18.04.amd64.deb
$ sudo apt-get install -f
On RPM-based systems:
$ wget https://github.com/jarun/googler/releases/download/v4.0/googler-4.0-1.el7.6.centos.x86_64.rpm
$ sudo rpm -ivh googler-4.0-1.el7.6.centos.x86_64.rpm
For other installation methods, refer official github page given at the end.
How To Google Search From Commandline Using Googler
Some of you might not know the advanced google search tricks, like searching only on a specific website, search for specific file type, search between range of number etc. However, we all do know how to do basic google search. Just type search term in the google search bar and pick one suitable from the search list. It is very easy!
Now let us see how to google search from commandline using googler. Trust me, it is very easy too!
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.
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.
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.
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
$ googler arch linux -w ostechnix.com
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 results for the given search query.
$ googler -n 3 ostechnix
Display results starting from nth result
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.
Integrate Googler with Text browsers
Googler can be integrated with several Text-browsers such as elinks, links, lynx and w3m or www-browser. This will work out of the box if the BROWSER environment variable is correctly set. For example:
$ export BROWSER=w3m
For one-time use,
$ BROWSER=w3m googler dns
Or, do site-specific search:
$ BROWSER=w3m googler -w ostechnix.com arch linux
This command will search for arch linux query in ostechnix.com. When you type the index number of any link and hit ENTER key, it will open in w3m browser by default.
To view the list of all supported options along with description, run:
$ googler --help
$ googler -h
You can also press the ? (question mark) to view the instant help section:
googler (? for help) ? 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 O [index|range|a ...] like key 'o', but try to open in a GUI browser g keywords new Google search for 'keywords' with original options should be used to search omniprompt keys and indices c index copy url to clipboard u toggle url expansion q, ^D, double Enter exit googler ? show omniprompt help * other inputs issue a new search with original options
- How To Search DuckDuckGo From Commandline Using ddgr
- Surfraw – A Commandline Interface To Popular Search Engines And 100+ Websites
- How To Search The Web From Terminal On Linux
- Google Search Navigator – Enhance Keyboard Navigation In Google Search
- How To Use Google Translate From Commandline In Linux
- GooBook – Access Your Google Contacts From Commandline In Linux
- DuckDuckGo Bangs – Search Directly On Your Favorite Websites
Hope this helps.