Git Product home page Git Product logo

ddgr's Introduction

ddgr

Latest release Availability PyPI Build Status Privacy Awareness License

Asciicast

ddgr is a cmdline utility to search DuckDuckGo (html version) from the terminal. While googler is extremely popular among cmdline users, in many forums the need of a similar utility for privacy-aware DuckDuckGo came up. DuckDuckGo Bangs are super-cool too! So here's ddgr for you!

Unlike the web interface, you can specify the number of search results you would like to see per page. It's more convenient than skimming through 30-odd search results per page. The default interface is carefully designed to use minimum space without sacrificing readability.

A big advantage of ddgr over googler is DuckDuckGo works over the Tor network.

ddgr isn't affiliated to DuckDuckGo in any way.

Donate via PayPal!

Table of contents

Features

  • Fast and clean; custom color
  • Designed for maximum readability at minimum space
  • Instant answers (supported by DDG html version)
  • Custom number of results per page
  • Navigation, browser integration
  • Search and option completion scripts (Bash, Fish, Zsh)
  • DuckDuckGo Bangs (along with completion)
  • Open the first result in browser (I'm Feeling Ducky)
  • REPL for continuous searches
  • Keywords (e.g. filetype:mime, site:somesite.com)
  • Limit search by time, specify region, disable safe search
  • HTTPS proxy support, optionally disable User Agent
  • Do Not Track set by default
  • Supports custom url handler script or cmdline utility
  • Privacy-aware (no unconfirmed user data collection)
  • Thoroughly documented, man page with examples
  • Minimal dependencies

Installation

Dependencies

ddgr requires Python 3.8 or later. Only the latest patch release of each minor version is supported.

To copy url to clipboard at the omniprompt, ddgr looks for wl-copy (only under Wayland) or xsel or xclip or termux-clipboard-set (in the same order) on Linux, pbcopy (default installed) on OS X, clip (default installed) on Windows and clipboard (default installed) on Haiku. It also supports GNU Screen and tmux copy-paste buffers in the absence of X11.

Note: v1.1 and below require the Python3 requests library to make HTTPS requests. This dependency is removed in the later releases.

From a package manager

Install ddgr from your package manager. If the version available is dated try an alternative installation method.

Packaging status (expand)


Packaging status

Unlisted packagers:


Awesome (awesome -install jarun/ddgr)
PyPI (pip3 install ddgr)
Snap Store (snap install ddgr)
Source Mage (cast ddgr)
● Termux (pip3 install ddgr)

From source

If you have git installed, clone this repository. Otherwise download the latest stable release or development version.

To install to the default location (/usr/local):

$ sudo make install

To remove ddgr and associated docs, run

$ sudo make uninstall

PREFIX is supported, in case you want to install to a different location.

Running standalone

ddgr is a standalone executable (and can run even on environments like Termux). From the containing directory:

$ ./ddgr

Shell completion

Search keyword and option 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.

Usage

Cmdline options

usage: ddgr [-h] [-n N] [-r REG] [--colorize [{auto,always,never}]] [-C]
            [--colors COLORS] [-j] [-t SPAN] [-w SITE] [-x] [-p URI]
            [--unsafe] [--noua] [--json] [--gb] [--np] [--url-handler UTIL]
            [--show-browser-logs] [-v] [-d]
            [KEYWORD [KEYWORD ...]]

DuckDuckGo from the terminal.

positional arguments:
  KEYWORD               search keywords

optional arguments:
  -h, --help            show this help message and exit
  -n N, --num N         show N (0<=N<=25) results per page (default 10); N=0
                        shows actual number of results fetched per page
  -r REG, --reg REG     region-specific search e.g. 'us-en' for US (default);
                        visit https://duckduckgo.com/params
  --colorize [{auto,always,never}]
                        whether to colorize output; defaults to 'auto', which
                        enables color when stdout is a tty device; using
                        --colorize without an argument is equivalent to
                        --colorize=always
  -C, --nocolor         equivalent to --colorize=never
  --colors COLORS       set output colors (see man page for details)
  -j, --ducky           open the first result in a web browser; implies --np
  -t SPAN, --time SPAN  time limit search [d (1 day), w (1 wk), m (1 month), y (1 year)]
  -w SITE, --site SITE  search sites using DuckDuckGo
  -x, --expand          Show complete url in search results
  -p URI, --proxy URI   tunnel traffic through an HTTPS proxy; URI format:
                        [http[s]://][user:pwd@]host[:port]
  --unsafe              disable safe search
  --noua                disable user agent
  --json                output in JSON format; implies --np
  --gb, --gui-browser   open a bang directly in gui browser
  --np, --noprompt      perform search and exit, do not prompt
  --rev, --reverse      list entries in reversed order
  --url-handler UTIL    custom script or cli utility to open results
  --show-browser-logs   do not suppress browser output (stdout and stderr)
  -v, --version         show program's version number and exit
  -d, --debug           enable debugging

omniprompt keys:
  n, p, f               fetch the next, prev or first set of search results
  index                 open the result corresponding to index in browser
  o [index|range|a ...] open space-separated result indices, ranges or all
  O [index|range|a ...] like key 'o', but try to open in a GUI browser
  d keywords            new DDG search for 'keywords' with original options
                        should be used to search omniprompt keys and indices
  x                     toggle url expansion
  c index               copy url to clipboard
  q, ^D, double Enter   exit ddgr
  ?                     show omniprompt help
  *                     other inputs are considered as new search keywords

Configuration file

ddgr doesn't have any! Use aliases, environment variables and auto-completion scripts.

Text-based browser integration

ddgr 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 ddgr query

Due to certain graphical browsers spewing messages to the console, ddgr suppresses browser output by default unless BROWSER is set to one of the known text-based browsers: currently elinks, links, lynx, w3m or www-browser. 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 --show-browser-logs.

If you need to use a GUI browser with BROWSER set, use the omniprompt key O. ddgr will try to ignore text-based browsers and invoke a GUI browser. Browser logs are always suppressed with O.

Colors

The color configuration is similar to that of googler colors. The default color string is oCdgxy. ddgr recognizes the environment variable DDGR_COLORS. Details are available in the ddgr man page.

Examples

  1. DuckDuckGo hello world:

    $ ddgr hello world
    
  2. I'm Feeling Ducky search:

    $ ddgr -j lucky ducks
    
  3. DuckDuckGo Bang search hello world in Wikipedia:

    $ ddgr !w hello world
    $ ddgr \!w hello world // in (some) shells (e.g. bash, zsh, tcsh) '!' character need to be escaped
    

    Bangs work at the omniprompt too. To look up bangs, visit https://duckduckgo.com/bang?#bangs-list.

  4. Bang alias to fire from the cmdline, open results in a GUI browser and exit:

    alias bang='ddgr --gb --np'
    $ bang !w hello world
    $ bang \!w hello world // in (some) shells (e.g. bash, zsh, tcsh) '!' character need to be escaped
    
  5. Website specific search:

    $ ddgr -w amazon.com digital camera
    

    Site specific search continues at omniprompt.

  6. Search for a specific file type:

    $ ddgr instrumental filetype:mp3
    
  7. Fetch results on IPL cricket from India in English:

    $ ddgr -r in-en IPL cricket
    

    To find your region parameter token visit https://duckduckgo.com/params.

  8. Search quoted text:

    $ ddgr it\'s a \"beautiful world\" in spring
    
  9. Show complete urls in search results (instead of only domain name):

    $ ddgr -x ddgr
    
  10. Use a custom color scheme, e.g., one warm color scheme designed for Solarized Dark:

    $ ddgr --colors bjdxxy hello world
    $ DDGR_COLORS=bjdxxy ddgr hello world
    
  11. Tunnel traffic through an HTTPS proxy, e.g., a local Privoxy instance listening on port 8118:

    $ ddgr --proxy localhost:8118 hello world
    

    By default the environment variable https_proxy (or HTTPS_PROXY) is used, if defined.

  12. Look up n, p, o, O, q, d keywords or a result index at the omniprompt: as the omniprompt recognizes these keys or index strings as commands, you need to prefix them with d, e.g.,

    d n
    d g keywords
    d 1
    

Troubleshooting

  1. Some users have reported problems with a colored omniprompt (refer to issue #40) with iTerm2 on OS X. To force a plain omniprompt:

    export DISABLE_PROMPT_COLOR=1
    

Notes

  1. The Albert Launcher python plugins repo (awesome-albert-plugins) includes suggestions-enabled search plugins for a variety of websites using ddgr. Refer to the latter for demos and usage instructions.

Collaborators

Copyright © 2016-2024 Arun Prakash Jana

In the Press

ddgr's People

Contributors

amasad avatar amdmi3 avatar andrew15-5 avatar arian-d avatar bergercookie avatar br1ght0ne avatar chenrui333 avatar crestwave avatar davidjharder avatar dstjacques avatar eclipseo avatar jarun avatar jorgesumle avatar kianmeng avatar kxxvii avatar marcelpaulo avatar markus1189 avatar mosegontar avatar mosrod avatar rtek-dev avatar signed-log avatar szlin avatar timb87 avatar vaygr avatar wuerfeldev avatar zmwangx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ddgr's Issues

[macOS] Prompt escape sequences error

Hey there @jarun , great project!

Small bug i've noticed is that, after conducting a search, the ddgr prompt is a bit funny due to possible syntax error.

On my machine I get this literal string for the prompt: [7mddgr (? for help)[0m

The code, should be something like this: '\e[7mddgr (? for help)\e[0m

$ echo -e '\e[7mddgr (? for help)\e[0m'
=> ddgr (? for help)

Does ddgr need to open a proxy?

My first search suggests:
[ERROR] HTTPSConnectionPool(host='duckduckgo.com', port=443): Max retries exceeded with url: /html (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fa26d8fbda0>: Failed to establish a new connection: [Errno 111] Connection refused',)))
No results.

Allow download files

I'd like to search for some files and download them, e.g. using the following query:

site:duckduckgo.com filetype:pdf

I've created similar tool google_dl, where I can run:

google_dl -s duckduckgo.com -f pdf ""

and it'll download all PDF files.

Can a similar feature be implemented in this tool?

[ERROR] string index out of range

$ ddgr -x -w "https://github.com" ""
[ERROR] string index out of range
$ ddgr --version
1.4

Normally you are able to search the site without a query.

Method to make a proxy setting persistant?

Say I had a proxy at 192.168.2.103:8118. How could I set ddgr up where I would never accidentally access the web without going through the proxy? In the past, I always did this through the browser settings - not as a global change to networking.

Any tips appreciated.

Missing 'requests' module

This problem might be with my python installation, but python seems to break so easily that, even if the problem is with my installation, others might have the same problem.

The problem is as follows.

~ $ ddgr test
Traceback (most recent call last):
  File "/usr/bin/ddgr", line 25, in <module>
    import requests
ImportError: No module named 'requests'

sudo -H pip install requests worked but did not prevent the above error message.
Linux Mint Cinnamon 18.3 x64

EDIT: here are some relevant details of my system.

~ $ which python
/usr/bin/python
~ $ python
Python 2.7.12 (default, Nov 20 2017, 18:23:56) 
[GCC 5.4.0 20160609] on linux2

Also: compiling from the git source did not solve the problem.

FURTHER EDIT:

$ python3 ddgr test
Traceback (most recent call last):
  File "ddgr", line 25, in <module>
    import requests
ImportError: No module named 'requests'

Allow instant results

Searching "time in london" should also bring up the instant result from DDG apart from the web results.

Add param to start at the specific page or index

Add equivalent param to start from n page/result.

Something like:

printf "n\nn\n" | ddgr "foo"

but in form of parameter, like: -p PAGE_NUM, so it can be combined with JSON param, as the following doesn't work anymore:

$ printf "n\nn\n" | ddgr --json "foo"

Index not shown opens in browser

~/G/ddgr$ ddgr news india --time d

 (1) India First: Church Or Chaiwalla - YouTube  [www.youtube.com]
breaking AAJ TAK News india today karvy Survey BJP set to sweep 19 states, modi first & last choice - Duration: 34:56. The Great PM Narendra Modi 410,762 ...

 (2) Ludhiana news | DiscussIndia  [www.discussindia.in]
LUDHIANA: A noteworthy fire gutted a four-storeyed working in Ludhiana's Suffian Chowk on Monday, prompting the fall of the plastic assembling plant ...

 (3) breaking news | DiscussIndia  [www.discussindia.in]
AHMEDABAD: Patidar share pioneer Hardik Patel got involved in a discussion on Monday as two sex video cuts supposedly demonstrating him with a lady ...

 (4) India: Grant approved for flood victims in Assam, India ...  [humanitariannews.org]
Source: Government of India Country: India The Government of the Hong Kong Special Administrative Region has accepted the advice of the Disaster Relief ...

 (5) 23 November, 2017 - Indianews23  [indianews23.com]
on the last day of the Kolkata Test versus Sri Lanka however the hosts resented Niroshan Dickwella's time-wasting tactics.India resisted valiantly after ...

 (6) News - indiawaterportal.org  [www.indiawaterportal.org]
India Water Portal is an Arghyam initiative. All content on this website is published. under a CC BY-NC-SA 2.5 IN license.

 (7) News & Updates Archives - Page 483 of 483 - Rolling Stone India  [rollingstoneindia.com]
Seven years after the folk music platform was formed, Oikyotaan remains committed to its indie roots and baul music

 (8) News Archives - Hub - mddir.com  [www.mddir.com]
Narendra Modi, in one single 10 minute announcement, has ensured that all corrupt and anti-social elements in India using black money to further their ...

 (9) tags related | SportingIndia  [sportingindia.com]
Latest News. Indian hockey squad trains at Bhubaneswar ahead of HWL Final. Nov,23 2017. ... India look to extend dominance in second Test. Nov,23 2017.

 (10) India minister says 'sin causes cancer' - 3News  [3news.com]
Indians have reacted angrily after the health minister from Assam state said cancer "is divine justice" caused by "past sins of a person". Himanta ...

ddgr (? for help) O 11
ddgr (? for help) n

 (1) Welcome to All India Football Federation  [www.the-aiff.com]
Contact. All India Football Federation, Football House, Sector 19, Phase 1 Dwarka, New Delhi: 110075 Telephone: 91-11-25308200/201/202/203/204/205

The 11th index opens up.

Bang operator should be changed to avoid conflicts with bash

It is very easy for bash users to forget to escape the ! bang operator. Many new users does not even know that bash will expand !.

Bash will replace !<letter> with the last command that started with <letter>.

Example:

jonny@localhost /tmp {1.8}{6.12.3} $ wget https://raw.githubusercontent.com/jarun/ddgr/master/README.md
--2018-02-07 13:28:24--  https://raw.githubusercontent.com/jarun/ddgr/master/README.md
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.84.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.84.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12999 (13K) [text/plain]
Saving to: ‘README.md’

README.md                     100%[==============================================>]  12.69K  --.-KB/s    in 0.03s   

2018-02-07 13:28:25 (410 KB/s) - ‘README.md’ saved [12999/12999]

jonny@localhost /tmp {1.8}{6.12.3} $ ddgr !w hello world
ddgr wget https://raw.githubusercontent.com/jarun/ddgr/master/README.md hello world

 (1) googler/README.md at master · jarun/googler · GitHub  [github.com]
googler / README.md. Fetching ... //raw.githubusercontent.com/jarun/googler/master/googler && sudo ... So when the
same user runs g -l de -c de -n 12 hello world, ...

 (2) LinuxUser - Das Magazin für die Praxis - Link-Archiv LinuxUser  [www.linux-user.de]
LinuxUser bietet jeden Monat auf 100 Seiten praxisorientierte Artikel, Workshops und News rund um Linux.

 (3) GitHub - jaymoulin/docker-ddgr: DuckDuckGo from the terminal ...  [github.com]
master Nothing to show ... README.md ddgr - Docker Image ... curl -sSL
"https://gist.githubusercontent.com/jaymoulin/e749a189511cd965f45919f2f99e45f3/raw ...

 (4) Tutoriais | semanickz | Página 2  [semanickzaine.wordpress.com]
... https://github.com/jarun/ddgr. ... sudo dnf -y install wget ; sudo rpm --import
https://raw.githubusercontent.com/kuboosoft/postinstallerf/master/GPG/$ ...

 (5) koma | Think Tank Blog | Seite 2  [think.unblog.ch]
Google-Suche ist die am meisten verwendete Suchmaschine im World Wide Web ( WWW ), um Informationen von Millionen
von Servern im Internet zu sammeln.

 (6) Googler - Command Line Google Search On Linux System - LookLinux  [www.looklinux.com]
... github master branch and upgrade Googler for latest stable version. # curl -o /usr/local/bin/googler
https://raw.githubusercontent.com/jarun/googler/master ...

 (7) 从终端使用Google Search, Google Site Search, Google News服务的工具 ...  [www.ctolib.com]
... if you want to install from git master ... bin/googler
https://raw.githubusercontent.com/jarun/googler/master/googler ... l de -c de -n 12 hello world, ...

 (8) 马刚博客 - 又一个WordPress站点  [ieee1888.win]
此外,Netfits、VPN Master Pro、Ponhon、Snap VPN 和 SkyX 等 VPN ... wget https: //bootstrap.pypa.io ... https:
//raw.githubusercontent.com/gfwlist/gfwlist ...

 (9) TODO after Ubuntu instalation · GitHub  [gist.github.com]
HTTPS Learn more about clone URLs Download ZIP Code Revisions 34. TODO after Ubuntu instalation ...

 (10) Googler: Cómo buscar en Google desde la Terminal Linux  [esgeeks.com]
Soporta servicios de proxy HTTPS; ... cd Downloads wget -c https://github.com/jarun ... sudo curl -o
/usr/local/bin/googler https://raw.githubusercontent.com/jarun ...

Add sub-pagination support

Add an option to show only n results per page and use sub-pages to navigate the results. Fetch new results when total number of results left to show < n and NOT last page reached.

Option to display full URLs

It would be nice to print the full URLs for the found pages, so one can use --np and still click on them on a suitable terminal emulator.

'site' related query ignored

For example, when I run:

ddgr -x "site:https://www.youtube.com/watch"

I get different results than I run the same query on the website. For example I get like gdata.youtube.com, or help.youtube.com.

It works when using googler.

What am I missing?

Problem with results: URLs not staring with 'www.' do not offer an open option

I'm using Gnome terminal, on Mint 18.3 Cinnamon. The results list contains URLs, coloured brown. Clicking or double-clicking them does nothing; but that's fair enough, since a context menu offers 'open link', and it works. However, one of my results - I searched for the word 'test' - starts not with 'www.' (which all the others did) but with '.beta', and it offered no 'open link' in the context menu. Is this a limitation of my terminal emulator? Thanks.

Support DuckDuckGo bangs

Probably we need to get the bang expansion in a separate query. Once we get that we should directly open the query in the browser instead of fetching results the usual way.

Cannot use text base browsers

When I try to use a text based browser (w3m or lynx) I receive the following error [ERROR] register() takes from 2 to 3 positional arguments but 4 were given. It does work with gui based browsers though.

Operating system: macOS High Sierra v10.13.6

I tried this on both normal bash/terminal and on zsh and got the same results.

w3m version:

➜  w3m -version
w3m version w3m/0.5.3+git20180125, options lang=en,m17n,color,ansi-color,mouse,menu,cookie,ssl,ssl-verify,external-uri-loader,w3mmailer,nntp,ipv6,alarm,mark

ddgr version:

➜  ddgr --version
1.4

query and command output:

➜  BROWSER=w3m ddgr django decorator require_post

 (1) View decorators | Django documentation | Django  [docs.djangoproject.com]
The decorators in django.views.decorators.http can be used to restrict access to views based on the ... require_POST()¶ Decorator to require that a view only accepts ...

 (2) Working with Django View Decorators - Simple is Better Than ...  [simpleisbetterthancomplex.com]
View decorators can be used to restrict access to certain views. Django come with some built-in decorators, like login_required, require_POST or has_permissi...

 (3) django.views.decorators.http | Django documentation | Django  [docs.djangoproject.com]
Source code for django.views.decorators.http ... require_POST. __doc__ = "Decorator to require that a view only ... archives of the django-users mailing list, or post ...

 (4) Decorator overwriting POST, GET and REQUEST in Django - doing ...  [stackoverflow.com]
In Django, I have created a function decorator which can - in this example - create a lowercase version of a supplied POST/GET argument, and it updates the REQUEST before the view
handles it all. ...

 (5) Creating class based view decorators using simple Django ...  [www.daveoncode.com]
For example let's consider we have a view that require a POST ... and this is the class decorator implementation: from django.views.decorators.http import ...

 (6) How to display a custom error page for HTTP status 405 ...  [stackoverflow.com]
My question is simple, how do I display a custom error page for HTTP status 405 (method not allowed) in Django when using the @require_POST decorator? I'm using the
django.views.decorators.http.

 (7) View decorators — Django 1.10 documentation  [django-document-korean.readthedocs.io]
The decorators in django.views.decorators.http can be used to restrict access to views based on the ... require_POST()¶ Decorator to require that a view only accepts ...

 (8) View decorators — Django 2.2.dev20180622141950 documentation  [django.readthedocs.io]
The decorators in django.views.decorators.http can be used to restrict access to views based on the ... require_POST ¶ Decorator to require that a view only accepts ...

 (9) How to secure your Django project by validating incoming ...  [www.twilio.com]
In this guide we'll cover how to secure your Django application by validating incoming requests to your Twilio webhooks are, in fact, from Twilio. With a few lines of code we'll
write a custom decorator for our Django project that uses the Twilio Python SDK's validator utility. We can then ...

 (10) Writing Django Views: Function Based Views ... - Program Everyday  [programeveryday.com]
Writing Django Views: Function Based Views, ... In FBVs I typically import django.views.decorators.http.require_POST and use that as a decorator to specify that the ...

ddgr (? for help) 1
[ERROR] register() takes from 2 to 3 positional arguments but 4 were given

Thanks for your hard work, and if there's anything I can do to help resolve this issue, let me know.

SSL: CERTIFICATE_VERIFY_FAILED every query

After installing from brew every query returns the following:

[ERROR] <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate (_ssl.c:1045)>

Disable colors by default, when piping

$ ddgr -x --np example | cat -v | head
^[[96m (1)^[[0m ^[[32;1mExample | Definition of Example by Merriam-Webster^[[0m
^[[33mhttps://www.merriam-webster.com/dictionary/example^[[0m
$ ddgr --version
1.4

I'm aware of -C, but I think disabling colors on non-interactive terminal usually is the default behaviour of many utils such as grep, rg, etc.

Opening Links in GUI browser within WSL (bash on windows) does not work

Not sure if specific to ddgr but I cannot open links with my default GUI browser when using ddgr in WSL

I've set browser ($BROWSER) to be /mnt/c/Program Files (x86)/Mozilla Firefox/firefox.exe

Distributor ID: Ubuntu
Description:    Ubuntu 16.04.3 LTS
Release:        16.04
Codename:       xenial
$ ddgr -d cheese
[DEBUG] ddgr version 1.2
[DEBUG] Python version 3.5.2
[DEBUG] q:cheese, region:us-en, page:0, curindex:1, safe:1
[DEBUG] nextParams:
[DEBUG] proxy:{'https': None}
[DEBUG] Response body written to '/tmp/ddgr-response-nu6ap22r'.
[DEBUG] Prev nextParams:
[DEBUG] Next nextParams: Keywords=cheese&xargs=12KPjg1slSrZquh831MeKMQeKUgRpd1tm58N0uXsYsfIwUpX9u6dFIEOacyZA6QO1xt77k%5FcDYpflNaKymwfaJExjXBRHcX726gZS7%5FYsrb%2DeWZZIezeZgn7Sy2tkTZXIFYk%2DBSQ%2E%2E&hData=12KPjg1qdOxJy7tuqnF9W2TeGj8m4%2E

 (1) Cheese.com - World's Greatest Cheese Resource  [cheese.com]
Cheese and wine, the perfect recipe for a great dinner party. Light or heavy; fruity or dry, learn more about the wonderful combinations.

 (2) Cheese - Wikipedia  [en.wikipedia.org]
Cheese is a dairy product derived from milk that is produced in a wide range of flavors, textures, and forms by coagulation of the milk protein casein.It comprises proteins and fat from milk, usually the milk of cows, buffalo, goats, or
sheep.

 (3) Cheese Recipes - Allrecipes.com  [www.allrecipes.com]
Looking for cheese recipes? Allrecipes has more than 4,840 trusted cheese recipes complete with how-to videos, ratings, reviews, and cooking tips.

 (4) Cheese - Walmart.com  [www.walmart.com]
Shop for Cheese in Dairy, Eggs & Cheese. Buy products such as 4C HomeStyle Parmesan Romano Grated Cheese, 6 oz, Velveeta Original Cheese 16 oz. Box at Walmart and save.

 (5) Cheese - definition of cheese by The Free Dictionary  [www.thefreedictionary.com]
cheese 1 (chēz) n. 1. a. A solid food prepared from the pressed curd of milk, often seasoned and aged. b. A molded mass of this substance. 2. Something resembling this ...

 (6) A Guide to Cheese | Whole Foods Market  [www.wholefoodsmarket.com]
Walk into our stores & you'll find some of the best cheeses in the world. Read up on all things cheese including types, cooking with cheese, & more.

 (7) Gourmet Cheese | Di Bruno Bros.  [dibruno.com]
Di Bruno Brothers carries the finest selection of artisan and gourmet cheese online. Shop online and get your gourmet cheese shipped directly to you.

 (8) Cheese - The New York Times  [www.nytimes.com]
News about cheese. Commentary and archival information about cheese from The New York Times.

 (9) Murray's Cheese | Gourmet Cheeses & Meats, Cheese of the ...  [www.murrayscheese.com]
Cheese and meat is one of the oldest pairings, and Olympia Provisions is one of America's foremost producers of artisanal meats—Bon Appetit calls them the country's best charcuterie, and they've won more Good Food Awards than any other
producer ever.

 (10) Chuck E. Cheese's - Where A Kid Can Be A Kid®  [www.chuckecheese.com]
Come experience great food and fun for all ages! Chuck E. Cheese's offers family fun and entertainment, Where A Kid Can Be A Kid®!

ddgr (? for help) O 1
[DEBUG] Opening https://cheese.com/
[DEBUG] <webbrowser.GenericBrowser object at 0x7fab6e768940>

and nothing happens

Using python directly (what looks to be the way the scripts opens a link) works great (opens a firefox window on my windows desktop)

Python 2.7.12 (default, Dec  4 2017, 14:50:18)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import webbrowser
>>> import pprint
>>> vars(webbrowser.get())
{'basename': 'firefox.exe', 'args': ['%s'], 'name': '/mnt/c/Program Files (x86)/Mozilla Firefox/firefox.exe'}
>>> webbrowser.open("www.github.com")
True

'ascii' codec can't encode character '\xe7' in position [...]: ordinal not in range(128)

Have just installed from master (141f5b7), and got this error when completing a word with non-ascii characters:

+paulo@monk:~/tmp$ ddgr --complete traduç
Traceback (most recent call last):
  File "/usr/local/bin/ddgr", line 1807, in <module>
    main()
  File "/usr/local/bin/ddgr", line 1737, in main
    completer_run(opts.complete)
  File "/usr/local/bin/ddgr", line 1670, in completer_run
    completions = completer_fetch_completions('+'.join(prefix.split()))
  File "/usr/local/bin/ddgr", line 1662, in completer_fetch_completions
    resp = urllib.request.urlopen(api_url, timeout=3)
  File "/usr/lib/python3.6/urllib/request.py", line 223, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.6/urllib/request.py", line 526, in open
    response = self._open(req, data)
  File "/usr/lib/python3.6/urllib/request.py", line 544, in _open
    '_open', req)
  File "/usr/lib/python3.6/urllib/request.py", line 504, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.6/urllib/request.py", line 1361, in https_open
    context=self._context, check_hostname=self._check_hostname)
  File "/usr/lib/python3.6/urllib/request.py", line 1318, in do_open
    encode_chunked=req.has_header('Transfer-encoding'))
  File "/usr/lib/python3.6/http/client.py", line 1239, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.6/http/client.py", line 1250, in _send_request
    self.putrequest(method, url, **skips)
  File "/usr/lib/python3.6/http/client.py", line 1117, in putrequest
    self._output(request.encode('ascii'))
UnicodeEncodeError: 'ascii' codec can't encode character '\xe7' in position 16: ordinal not in range(128)

Running python 3.6.3 on Xubuntu 17.10 with xfce4-terminal 0.8.6 + tmux (b5c0b2ca), and these locale:

+paulo@monk:~/tmp$ locale
LANG=en_US.UTF-8
LANGUAGE=en_US
LC_CTYPE=pt_BR.UTF-8
LC_NUMERIC=pt_BR.UTF-8
LC_TIME=pt_BR.UTF-8
LC_COLLATE="en_US.UTF-8"
LC_MONETARY=pt_BR.UTF-8
LC_MESSAGES="en_US.UTF-8"
LC_PAPER=pt_BR.UTF-8
LC_NAME=pt_BR.UTF-8
LC_ADDRESS=pt_BR.UTF-8
LC_TELEPHONE=pt_BR.UTF-8
LC_MEASUREMENT=pt_BR.UTF-8
LC_IDENTIFICATION=pt_BR.UTF-8
LC_ALL=

Support navigation

Any idea to implement this feature? Looking at the source code of the Next button (https://duckduckgo.com/html/?q=asd) it may seem trivial to build a URL for the next and previous pages:

<form action="/html/" method="post">
          <input type="submit" class='btn btn--alt' value="Next" />
          <input type="hidden" name="q" value="asd" />
          <input type="hidden" name="s" value="30" />
          <input type="hidden" name="nextParams" value="Keywords=asd&amp;xargs=12KPjg1pZSrp68i%2D%5FoMPCRErjGnQNVmZ615JIuTcQ%5FQZAD6A5dYdR%5FePqBypItDrUtu0KJk6nQo%5FpPIfD7ucu6&amp;hData=12KPjg1qdOxJy7tuqnF9W2TOSj8m4%2E" />
          <input type="hidden" name="v" value="l" />
          <input type="hidden" name="o" value="json" />
          <input type="hidden" name="dc" value="31" />
          <input type="hidden" name="api" value="/d.js"/>
          <input name="kl" value="us-en" type="hidden" />
</form>

But https://duckduckgo.com/html/?q=sample&s=30&dc=31 just shows a website with the following message:

If this error persists, please let us know: [email protected]

ddgr exits with status 1 when LANG is not set

If LANG env variable is not set (default on OpenBSD) and search result have unicode chars with ordinal greater than 127 ddgr is killed.

Steps to reproduce:

  1. unset LANG environment variable
  2. issue ddgr merhaba
  3. result is the error message like this:
obsd-current$ ddgr merhaba 

 (1) merhaba - Wiktionary  [en.wiktionary.org]
This page was last edited on 20 November 2017, at 18:09. Text is available under
the Creative Commons Attribution-ShareAlike License; additional terms may ...

 (2) merhaba - English translation - bab.la Turkish-English dictionary  [en.bab.la]
Translation for 'merhaba' in the free Turkish-English dictionary and many other
English translations.

 (3) merhaba : definition of merhaba and synonyms of merhaba (Turkish)  [dictionary.sensagent.com]
Definitions of merhaba, synonyms, antonyms, derivatives of merhaba, analogical
dictionary of merhaba (Turkish)

 (4) The word merhaba? | Yahoo Answers  [answers.yahoo.com]
Merhaba is originally an Arabic word that entered the Turkish language (with
thousands of others) through Islam and the Ottoman Empire taking control of ...

 (5) Ahmet Kaya - Merhaba - YouTube  [www.youtube.com]
[ERROR] 'ascii' codec can't encode character '\u011f' in position 53: ordinal not in range(128)

Bug does not exist when LANG is set to something that can cope with UTF-8. Is it possible to 'sanitize' output according to current locale?

Bug was encountered when testing port of ddgr to OpenBSD so please consider this issue also as an announcement of OpenBSD port.

way to limit results to only N lines?

If I have to scroll back in terminal to see the first result, it is too much trouble. and I almost never look at results way down the list anyway. So I'd like to tell ddgr to only show results that can be displayed in e.g. 50 lines or less, so it all fits on one screen. I didn't see a way to do this

seq fault on Cntrl-q

when I do ddgr hello world, then type Cntrl-q at the prompt, ddgr dies with a seg fault

It would be sort of nice if Cntrl-q also meant quit. I have a bit of a crazed personal mission of making
Cntrl-q mean "get rid of the current thing" across all my software. Of course it sort of works as it is so maybe I shouldn't be reporting this issue :)

E: Unable to locate package ddgr in WSL

Hey, neither googler nor ddgr are found for me when doing apt install. Do I need to add new sources or something first? If so, can you mention the complete installation steps in the README?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.