ducksearch (588B)
1 #!/usr/bin/env sh 2 # Gives a dmenu prompt to search DuckDuckGo. 3 # Without input, will open DuckDuckGo.com. 4 # URLs will be directly handed to the browser. 5 # Anything else, it search it. 6 browser=${BROWSER:-firefox} 7 8 pgrep -x dmenu && exit 9 10 choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1 11 12 if [ "$choice" = "🦆" ]; then 13 $browser "https://duckduckgo.com" 14 else 15 if echo "$choice" | grep "^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$"; then 16 $browser "$choice" 17 else 18 $browser "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1" 19 fi 20 fi