3 ms·
lite is amazeballs as a command-line utility (leveraging any of several console-mode browsers, including w3m, lynx, links, elinks2, etc.). As a bash (or zsh) f
by dredmorbius 6y ago
lite is amazeballs as a command-line utility (leveraging any of several console-mode browsers, including w3m, lynx, links, elinks2, etc.).
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.
- mcdevilkiller 6y agoWow, that's amazing!
- vanderZwan 6y agoSimilarly, in Firefox (and maybe other browsers) you can add keywords to bookmarks, meaning that the browser will open that bookmark if you first type the keyword. It will also then insert anything else you type into the bookmarked URL if it has a %s. So as an alternative, more reliable way to search MDN, I bookmarked this: 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 go
- dredmorbius 6y agoThe benefit to bookmarks / keywords is flexibility and not having to wait for DDG to add (or fix) a given bang search. The 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.)
- boogies 6y agoHave you heard of Julian Assange’s surfraw? $ 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=foo
- dredmorbius 6y agoYep, both the tool and its author. I also use dict, have Debian's gazeteer TIGER files & miscfiles installed, dwww, RFCs, and more. Info-on-tap is wonderful.
- rkta 6y agoWhat is the &kd=-1 for? edit: To answer my own question https://duckduckgo.com/params https://duckduckgo.com/params