Summary

  • ddgr lets you search DuckDuckGo via the terminal, presenting clear results with URLs and descriptions.
  • You can install ddgr with a package managers like apt or Homebrew.
  • Use ddgr to search efficiently, open results in your browser, and refine searches with various command-line options.

Ever wanted to search the web without leaving your Linux terminal? The ddgr program lets you do just that using the DuckDuckGo search engine.

What Is ddgr?

ddgr is a command-line tool that lets you search DuckDuckGo, the privacy-respecting alternative to Google. DuckDuckGo sources its data from Bing and other sources, to provide excellent results.

Once you run a search in ddgr, you’ll see a list of results with the most important information in each: URL, title, and description. You can then use the interactive interface to open any of these results in your browser.

If you’re a big fan of the terminal, you’ll be spending a lot of time in it, and ddgr provides a lot of convenience. By presenting its results in clear, focused text, it lets you concentrate on what matters most: choosing the result that serves you best.

Three items at the end of a list of search results, each showing a title, domain, and description.

ddgr prominently displays the domain of each result, so you can focus on the source. But you can configure the tool to show full URLs, and change its behavior in many other ways.

How to Install ddgr

ddgr is widely available via almost any package manager you might be using. You can install it on Ubuntu using apt:

sudo apt install dodger

On macOS, your best option is Homebrew:

brew install ddgr

There’s also a snap package and you can install ddgr using pip3 if these options are unsuitable. Full instructions are available in the project’s README, including details on how to build the program from source.

Using ddgr to Search the Web

Once installed, you can run ddgr from the command line and pass search terms as parameters, for example:

ddgr vampire squid

You’ll see a list of ten results and a prompt for further input. To open a result in your browser, enter the index number alongside it.

The specific browser that ddgr uses will depend on your environment. By default, ddgr opened results in Chrome for me, and this was a quick and smooth process. If you want to use a terminal-based browser instead, you can do so by setting the BROWSER environment variable:

BROWSER=lynx ddgr bobtail squid

You can run another search using ddgr’s prompt, which is also useful if you start it without a search query. Just type your search query and press Enter.

There are many other commands you can run via the interactive prompt; list them all by typing ? and hitting Enter. The list of ten results that ddgr shows is just the first page. If you’re interested in other pages of your results, use n, p, and f to move to the next, previous, or first page. If you’ve found a good result, but don’t want to open it right away, you can copy the URL using c followed by its index.

One feature that I find especially useful is the command to open several results at once. For example, type the following in ddgr’s prompt to open the 1st, 3rd, 4th, and 5th results:

o 1 3-5

Each result will open in its own browser tab, and this process can be faster than using the mouse to open individual results from a web page.

ddgr also supports a few useful command-line options to vary its behavior.

ddgr’s command-line options including --num, --time, and --site.

To change the default number of results per page, use -n:

ddgr -n 5 bottletail squid

You can use -t to specify a time limit or –site to search a specific site. If you want to write a script involving search results, the –json option will come in handy: it returns results in JSON format, perfect for further processing:

JSON-formatted search results from ddgr, an array of objects each containing an abstract, title, and url.

Possibly my favorite touch, the –ducky option opens your first result in a browser automatically. It’s a play on words on the “I’m feeling lucky” feature that Google’s home page has included since the beginning.

ddgr --ducky a cute squid

If you enjoy working in the terminal, learn how to browse the web with Lynx or how to listen to Spotify in a terminal.