st/st-urlhandler
Pierguido Lambri 7e5b697352 Fixed a small issue with the urlhandler.
Urls lile:

https://whatever.domain/~myprecious/usefull-blog.html
https://brb.imback.maybe/isit/blah#sure

Were not propery handled (everything after either '#' or '~' were ignored).
Escaped '#' and added '~' in the regex.

Signed-off-by: Pierguido Lambri <plambri@redhat.com>
2020-08-07 09:53:57 +01:00

16 lines
487 B
Bash
Executable File

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