st-urlhandler 487 B

123456789101112131415
  1. #!/bin/sh
  2. urlregex="(((http|https)://|www\\.)[a-zA-Z0-9.]*[:]?[a-zA-Z0-9./@$&%?$\#=_~-]*)|((magnet:\\?xt=urn:btih:)[a-zA-Z0-9]*)"
  3. # First remove linebreaks and mutt sidebars:
  4. urls="$(sed 's/.*│//g' | tr -d '\n' |
  5. grep -aEo "$urlregex" | # grep only urls as defined above.
  6. uniq | # Ignore neighboring duplicates.
  7. sed 's/^www./http:\/\/www\./g')"
  8. [ -z "$urls" ] && exit
  9. chosen="$(echo "$urls" | dmenu -i -p 'Follow which url?' -l 10)"
  10. setsid xdg-open "$chosen" >/dev/null 2>&1 &