24 lines
548 B
Plaintext
24 lines
548 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
QUERY=$@
|
||
|
|
||
|
if [[ -z $QUERY ]]; then
|
||
|
QUERY=$(dmenu -p "Search Query: " < /dev/null )
|
||
|
fi
|
||
|
|
||
|
[[ -n $QUERY ]] || exit
|
||
|
|
||
|
QUERY=$(echo $QUERY | sed 's/ /+/g')
|
||
|
|
||
|
RESULT=$(curl "http://s.herisson.ovh/search?q=$QUERY&format=json")
|
||
|
|
||
|
TITLES=$(echo "$RESULT" | jq -r '.results[] | .title')
|
||
|
LINKS=$(echo "$RESULT" | jq -r '.results[] | .url')
|
||
|
|
||
|
SELECT=$(paste -d ": " <(seq $(echo "$TITLES" | wc -l)) <(echo "$TITLES") <(echo "$LINKS")| dmenu -l 15 | cut -d: -f1)
|
||
|
|
||
|
[[ -n $SELECT ]] || exit
|
||
|
|
||
|
echo "$LINKS" | head -n $SELECT | tail -1 | xclip -sel clip
|
||
|
|