summaryrefslogtreecommitdiff
path: root/bin/guiscripts/sturl
blob: 2712d922c7e4a80b5822bf30024dc3845202631f (plain)
1
2
3
4
5
6
7
8
9
10
11
#!/bin/sh

regex='(((file|https?|gopher|gemini|ftps?|git)://|www\.)[a-zA-Z0-9.]*[:;!a-zA-Z0-9./+@$&%?$\#=_~-]*)|(magnet:\?xt=urn:btih:[a-zA-Z0-9]*)'
url="$(tr -d '\n' | grep -Eo "$regex" | commander -xcl)"
[ -z "$url" ] && exit 1

case $1 in
	'c') printf '%s' "$url" | clipp ;;
	'o') lh "$url" ;;
	*) echo "no option" ;;
esac