First Commit
This is a first dotfiles config. I think I have a lot more to add tho...
This commit is contained in:
22
bin/.bin/search_open
Executable file
22
bin/.bin/search_open
Executable file
@ -0,0 +1,22 @@
|
||||
#!/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 | xargs xdg-open
|
Reference in New Issue
Block a user