~kris/suckless

st

ref: 3bb3315d3ba370d4db3c84b62d7e5f5b5f7731d3 st/st-urlhandler -rwxr-xr-x 487 bytes
3bb3315d — Kris Yotam switch terminal colorscheme to Plan 9 palette, set border to 4px 3 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/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 &