summaryrefslogtreecommitdiff
path: root/st-urlhandler
blob: 1ed2b23330424b09a686bbbecdf37e8d1f08383d (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" ] && echo "$urls" | dmenu -i -l 15 -p 'Select URL' \
                                 | xclip -r -sel c