For urxvt there is a nice perl extension called url-select, written by Bert Muennich. It was fine until I needed a few more options, especially an option for opening the selected url in an alternative browser. So I made a slight modification: added an option for it, then added another option for opening the selected url with a media player, which is useful for youtube or some other video links. I renamed this modified script to url-select-plus to avoid naming conflicts.
Update (03/10/2016): I added another option for an image viewer, now you can open image links directly with it (see: imgviewer
option).
Now I can use these options in my .Xresources file:
URxvt.url-select-plus.altlauncher: chromium
URxvt.url-select-plus.mediaplayer: mpv
URxvt.url-select-plus.imgviewer: feh
Then I can hit O
(Shift+o) to open the selected link in the alternative browser, which for me is Chromium.
If it’s a youtube link, then I can hit m
on the link and it will open the video in mpv. Of course, you can use it with another media player (mplayer, for example), just make sure you have youtube-dl installed.
You can find this extension in my dotfiles repo: url-select-plus
If you use this instead of the original url-select, don’t forget to modify the names for other options too in the .Xresources file:
URxvt.keysym.M-f: perl:url-select-plus:select_next
URxvt.url-select-plus.launcher: firefox
URxvt.url-select-plus.altlauncher: chromium
URxvt.url-select-plus.mediaplayer: mpv
URxvt.url-select-plus.imgviewer: feh
URxvt.url-select-plus.button: 1
URxvt.url-select-plus.underline: true