summaryrefslogtreecommitdiff
path: root/bin/guiscripts/sturl
blob: 5b8b1e76388fb487371ae48c9d032a37e7aabaab (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" | tac | commander -cl)"
[ -z "$url" ] && exit 1

case $1 in
	'c') printf '%s' "$url" | xclip -sel c -r ;;
	'o') linkhandler "$url" ;;
	*) echo "no option" ;;
esac