LinuxCommandLibrary

ddgr

Search DuckDuckGo from the command line

TLDR

Start in interactive mode

$ ddgr
copy

Search DuckDuckGo for a keyword
$ ddgr [keyword]
copy

Limit the number of search results to n
$ ddgr [[-n|--num]] [n] [keyword]
copy

Display the complete URL in search results
$ ddgr [[-x|--expand]] [keyword]
copy

Search DuckDuckGo for a keyword and open the first result in the browser
$ ddgr !w [keyword]
copy

Perform a website-specific search
$ ddgr [[-w|--site]] [site] [keyword]
copy

Search for a specific file type
$ ddgr [keyword] filetype:[filetype]
copy

Display help in interactive mode
$ <?>
copy

SYNOPSIS

ddgr [options] keywords

PARAMETERS

-n
    Number of results to display (default is 10).

-w
    Maximum width of text (default is 80, auto-detects if 0).

-o
    Open the first result in a web browser.

-O
    Open the nth result in a web browser.

-j
    JSON output.

-d
    DuckDuckGo region (country code, e.g., us, de, fr). Defaults to user's IP country.

-t
    Time limit for results (e.g., y1 for past year, m6 for past 6 months).

-s
    Search only within a specific site.

-k
    Add a keyword for searching.

-x
    Turn off ANSI color.

-u
    Fetch URL of a result (useful for checking redirects).

--lucky
    Open the first search result directly in the browser, like 'I'm Feeling Lucky'.

--version
    Show program's version number and exit.

-h, --help
    Show help message and exit.

--alias ="parameters"
    Define alias.

--clear-alias
    Clear alias.

--list-alias
    List alias.

-C
    Use curl instead of requests. May require dependencies setup.

DESCRIPTION

ddgr is a command-line utility that allows you to search DuckDuckGo (and other search engines) directly from your terminal without needing a web browser. It provides a clean, text-based interface to view search results, allowing users to quickly find information without the distractions of a typical web browser. ddgr supports keywords, site-specific searches, time constraints, and number of results. It can be particularly useful for developers, system administrators, and anyone who prefers a command-line interface for information retrieval. It can also use curl (instead of the default requests) to reduce dependencies.

CAVEATS

Requires Python and optionally, but preferably, the 'requests' or 'curl' library to be installed. The quality of search results depends on DuckDuckGo's search algorithm.

CONFIGURATION

ddgr stores its configuration file at ~/.ddgr_config.json which stores settings like number of results and country. The config file can be edited to change default behavior.

HISTORY

ddgr was developed as a lightweight and privacy-respecting alternative to using a web browser for searching DuckDuckGo. It aims to provide a fast and efficient way to find information from the command line. It has gained popularity among users who prioritize command-line workflows and privacy.

SEE ALSO

curl(1), wget(1)

Copied to clipboard