summaryrefslogtreecommitdiff
path: root/st-urlhandler
blob: d6deecf7c578d7d834c3e230562b9e5a42074700 (plain)
1
2
3
4
5
6
7
8
9
10
11
#! /bin/sh

urlregex="(((http|https|gopher|gemini|ftp|ftps|git)://|www\\.)[a-zA-Z0-9.]*[:;a-zA-Z0-9./+@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"

urls="$(sed 's/.*│//g' | tr -d '\n' \
                       | grep -aEo "$urlregex" \
                       | uniq \
                       | sed "s/\(\.\|,\|;\|\!\\|\?\)$//;s/^www./http:\/\/www\./")"

[ ! -z "$urls" ] && printf '%s' "$urls" | dmenu -i -l 15 -p 'Select URL' \
                                        | xclip -r -sel c