mirror of
https://git.davidovski.xyz/dot.git
synced 2024-08-15 00:43:28 +00:00
23 lines
579 B
Bash
Executable file
23 lines
579 B
Bash
Executable file
#!/bin/sh
|
|
#
|
|
#
|
|
# TODO make this list results in rofi/dmenu that would be coo
|
|
|
|
default_browser="links-launcher"
|
|
BROWSER=${BROWSER:-$default_browser}
|
|
SEARCH_ENGINE="https://search.davidovski.xyz/search.php?q="
|
|
SEARCH_HISTORY=$HOME/.local/share/search_history
|
|
|
|
SEARCH=$(cat $SEARCH_HISTORY | dmenu -p "search")
|
|
|
|
[ -z "$SEARCH" ] && exit 1
|
|
|
|
echo "$SEARCH" >> $SEARCH_HISTORY
|
|
|
|
query=$(echo $SEARCH | sed 's/ /+/g')
|
|
|
|
echo $query | grep -q '(?=^.{5,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)' && {
|
|
$BROWSER "$query"
|
|
} || {
|
|
$BROWSER "$SEARCH_ENGINE$query"
|
|
}
|