• 29 Posts
  • 523 Comments
Joined 3 years ago
cake
Cake day: December 10th, 2023

help-circle



  • You could write a bash script to do it and perform searches from the terminal. It will open a new tab or window in your browser with the term you entered with the appropriate settings. Then set the bash script as an alias to make it easier to use. I found a similar script and modified it for ddg. doesn’t seem to work 100% though, per usual it works on my machine, as-is no warranty, you need to install jq first if you already haven’t.

    #!/bin/bash
    
    # Check if a search term was provided
    if [ -z "$1" ]; then
        echo "Usage: $0 <search_term>"
        exit 1
    fi
    
    # URL encode the search term (handles spaces and special characters)
    encoded_search=$(printf '%s' "$1" | jq -sRr @uri)
    
    # Construct the DuckDuckGo search URL with a date filter for content before Jan 1, 2020
    duckduckgo_url="https://duckduckgo.com/?q=%24encoded_search&ia=web&t=h_&df=on&dfdate=before-2020-01-01"
    
    # Open the URL in a new browser tab (works with most common browsers)
    xdg-open "$duckduckgo_url" 2>/dev/null || open "$duckduckgo_url"