st

fork of st
git clone git://popovic.xyz/st.git
Log | Files | Refs | README | LICENSE

st-urlhandler (487B)


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