by dredmorbius · 5y ago · 0 comments
As a bash (or zsh) function:
ddg ()
{
/usr/bin/w3m "https://duckduckgo.com/lite?q=$*&kd=-1"
}
Note that this enables any bang searches as well, though you'll need to single quote these to avoid attempted history expansion.lite is also my default w3m search bookmark entry.
So:
ddg '!w foo' # Wikipedia article on foo
ddg '!dict foo' # Dictionary search on foo
ddg '!etym foo' # Etymology Dictionary search on foo
Note that if the endpoint itself relies on JS for local search, the bang won't be successful (though DDG will do its bit). Reddit, and HN/Algolia, I'm looking at you.I happened to be running some quick lookups a few days ago while a friend was watching, and they 1) wondered how I was doing that and 2) if they could have a similar feature. Power of the shell.
https://duckduckgo.com/lite/?q=site%3Adeveloper.mozilla.org+%s
... and gave it the keyword >mdn (I add ">" as a prefix to all my keyworded bookmarks - avoid accidentally triggering or autocompleting to them).If I'm browsing and need to look something up, I just hit CTRL+L followed by
>mdn [whatever I'm looking for]
... and off we goThe downside is that you're speaking your own language, and unless someone adopts your specific keywords, you can't tell them to, say, "bang dict" (if you can get away with saying that in the context).
This is a fundamental distinction between any private vs. shared language.
(People are very uncomfortable when dropped into my computing environment --- GUI, shells, editors, browsers, etc. They've all acquired several decades of personalisation. Works for me.)
$ alias d='sr duckduckgo -text -ducky'
$ d '!man surfraw'
[www-browser opens http://manpages.org/surfraw]
[…]
DESCRIPTION
Surfraw provides a fast unix command line interface to a variety of popular WWW search engines and other artifacts of power. It reclaims google, altavista, dejanews, freshmeat, research index, slashdot and many others from the false-prophet, pox-infested heathen lands of html-forms, placing these wonders where they belong, deep in unix heartland, as god loving extensions to the shell.
[…]
Edit: even better, dict(1) (or GNU dico): $ dict foo # same text as !dict’s http://dict.org/bin/Dict?Form=Dict2&Database=*&Query=fooI also use dict, have Debian's gazeteer TIGER files & miscfiles installed, dwww, RFCs, and more.
Info-on-tap is wonderful.
edit: To answer my own question https://duckduckgo.com/params