Skip to content

Instantly share code, notes, and snippets.

@creeper6530
Last active May 4, 2023 17:13
Show Gist options
  • Save creeper6530/b1831f7b8724976154a430f2143801bb to your computer and use it in GitHub Desktop.
Save creeper6530/b1831f7b8724976154a430f2143801bb to your computer and use it in GitHub Desktop.
DuckDuckGo search in Linux terminal

Installation

  1. Save the script, for example, as ddg
  2. Run sudo chmod a+x ddg
  3. Move the script into your PATH folder
  4. Enjoy!

Dependencies

  • Bash
  • Python 3 (should be preinstalled on most distros)
  • Lynx (isn't usually preinstalled, install it with sudo apt install lynx or the corresponding packet manager for your distro

Examples

  • $ ddg - opens DuckDuckGo in Lynx
  • $ ddg Bad bash examples - searches for "Bad bash examples"
  • $ ddg Die Umläute - it works with non-ascii chars as well
#!/bin/bash
url="https://lite.duckduckgo.com/lite?q="
value="$*"
encoded_value=$(python3 -c "import urllib.parse; print(urllib.parse.quote('''$value''', safe=''))")
lynx ${url}${encoded_value} -trace
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment