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