Detect http urls in query and directly connect to them
This commit is contained in:
parent
1adb9b9002
commit
6833d84077
1 changed files with 10 additions and 7 deletions
|
@ -1,15 +1,18 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# Gives a dmenu prompt to search DuckDuckGo.
|
browser=${BROWSER:-firefox}
|
||||||
# Without input, will open DuckDuckGo.com.
|
|
||||||
# Anything else, it search it.
|
|
||||||
|
|
||||||
pgrep -x dmenu && exit
|
pgrep -x dmenu && exit
|
||||||
|
|
||||||
choice=$(echo "🦆" | dmenu -i -p "Search DuckDuckGo:") || exit 1
|
query=$(echo "duckduckgo.com" | dmenu -i -p "Search DuckDuckGo:") || exit 1
|
||||||
|
|
||||||
if [ "$choice" = "🦆" ]; then
|
if [ "$query" = "duckduckgo.com" ]; 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 [[ "$query" =~ ^(http:\/\/|https:\/\/)?[a-zA-Z0-9]+.[a-zA-Z]+(/)?.*$ ]]; then
|
||||||
|
$browser "$query"
|
||||||
|
else
|
||||||
|
$browser "https://duckduckgo.com/?q=$query&t=ffab&atb=v1-1"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue