summaryrefslogtreecommitdiff
path: root/.uzbl/scripts/url_from_surfraw.sh
blob: bf3c5014c0107e23cfc68e6984e82f79d56cc45d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env bash
DEFAULT_SEARCH=startpage
string=$1
cmd=$2
set -- $string
is_elvi=$(surfraw -elvi | grep -c "^$1\s")
nbr_words=$(echo "$string" | wc -w)
if [ "$nbr_words" -eq 1 ] && [ "$is_elvi" -eq 0 ] && ([[ "$string" == *.* ]] || [[ "$string" == *:* ]])
then
    url="$1"
elif [ $is_elvi -eq 1 ]
then
    url="$(surfraw -print $string)"
else
    url="$(surfraw -print $DEFAULT_SEARCH $string)"
fi
echo "$cmd $url" > $UZBL_FIFO