Merge pull request #160 from anders-dc/ducksearch
Detect http urls in ducksearch and directly connect to them
This commit is contained in:
commit
4f53a2425b
1 changed files with 9 additions and 2 deletions
|
@ -2,14 +2,21 @@
|
||||||
|
|
||||||
# Gives a dmenu prompt to search DuckDuckGo.
|
# Gives a dmenu prompt to search DuckDuckGo.
|
||||||
# Without input, will open DuckDuckGo.com.
|
# Without input, will open DuckDuckGo.com.
|
||||||
|
# URLs will be directly handed to the browser.
|
||||||
# Anything else, it search it.
|
# Anything else, it search it.
|
||||||
|
browser=${BROWSER:-firefox}
|
||||||
|
|
||||||
pgrep -x dmenu && exit
|
pgrep -x dmenu && exit
|
||||||
|
|
||||||
choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
|
choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
|
||||||
|
|
||||||
if [ "$choice" = "🦆" ]; then
|
if [ "$choice" = "🦆" ]; then
|
||||||
$BROWSER "https://duckduckgo.com"
|
$browser "https://duckduckgo.com"
|
||||||
else
|
else
|
||||||
$BROWSER "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
|
# Detect if url
|
||||||
|
if [[ "$choice" =~ ^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+\.[a-zA-Z]+(/)?.*$ ]]; then
|
||||||
|
$browser "$choice"
|
||||||
|
else
|
||||||
|
$browser "https://duckduckgo.com/?q=$choice&t=ffab&atb=v1-1"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue