#! /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