dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles
Log | Files | Refs | README | LICENSE Back to index

commit 84a44a4463649baa73a9a7aa26cffa183aa419f3
parent 663a8f84106ac32f5123fd357fbb69255e085081
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed, 19 Dec 2018 10:13:09 +0100

Modify ducksearch to allow direct url entries

Diffstat:
Mlinks/bin/ducksearch | 14+++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/links/bin/ducksearch b/links/bin/ducksearch @@ -4,10 +4,18 @@ browser=${BROWSER:-firefox} pgrep -x dmenu && exit -choice=$(echo "duckduckgo.com" | dmenu -i -p "Search DuckDuckGo:") || exit 1 +query=$(echo "duckduckgo.com" | dmenu -i -p "Search DuckDuckGo:") || exit 1 -if [ "$choice" = "duckduckgo.com" ]; then +if [ "$query" = "duckduckgo.com" ]; then + echo go to ddg $browser "https://duckduckgo.com" 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 + echo this is a url + $browser "$query" + else + echo this is not a url + $browser "https://duckduckgo.com/?q=$query&t=ffab&atb=v1-1" + fi fi