dot/scripts/websearch

18 lines
451 B
Text
Raw Normal View History

2021-10-09 21:20:41 +00:00
#!/bin/sh
2022-05-15 23:48:34 +00:00
browser="links-launcher"
SEARCH_ENGINE="https://librex.beparanoid.de/search.php?q="
SEARCH_HISTORY=$HOME/.local/share/search_history
2021-10-09 21:20:41 +00:00
SEARCH=$(cat $SEARCH_HISTORY | dmenu -p "search")
2022-05-15 23:48:34 +00:00
echo "$SEARCH" >> $SEARCH_HISTORY
2021-10-09 21:20:41 +00:00
2022-05-15 23:48:34 +00:00
query=$(echo $SEARCH | sed 's/ /+/g')
2021-10-09 21:20:41 +00:00
2022-05-15 23:48:34 +00:00
echo $query | grep -q '(?=^.{5,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)' && {
links-launcher "$query"
} || {
links-launcher "$SEARCH_ENGINE$query"
}