Passing clicked links in rxvt to a script

I start my browser vimprobable in tabbed like so:

"`tabbed -d > /tmp/tabbed.xid`; vimprobable2 -e `cat /tmp/tabbed.xid`" [1]

I am then able to send all new instances of vimprobable to tabbed (and not have a new master window open), in other apps, eg., mutt, by:

vimprobable2 -e $(cat /tmp/tabbed.xid) %s

I would like to achieve the same thing in Urxvt.

Currently my .Xdefaults contains the matcher arguments:

URxvt.perl-ext-common: default,matcher
URxvt.urlLauncher: vimprobable2
URxvt.matcher.button: 1

I have changed the launcher line to point at a wrapper script:


Which is just:

vimprobable2 -e $(cat /tmp/tabbed.xid) %s &

but this just opens a browser instance in tabbed with the default search engine result for & (or %s if I remove the ampersand).

I have tried with other obvious variables, like "$1" and "[email protected]" – they don’t work either.

How do I pass the URL to the wrapper script?

[1] This also feels like a useless use of cat, so alternative suggestions would be welcome


The help text for the matcher PERL extension to urxvt states:

When clicked with the mouse button specified in the matcher.button resource (default 2, or middle), the program specified in the matcher.launcher resource (default, the urlLauncher resource, sensible-browser) will be started with the matched text as first argument.

therefore, you need to set URxvt.matcher.launcher to a script that takes a single argument (in sh-type shells, this is spelt $1) and open it. For example:

#! /bin/sh

exec vimprobable2 -e $(cat /tmp/tabbed.xid) "$1"

Note: It’s advisable to quote the $1 argument to prevent the shell from interpreting meta-characters that may appear in the URL (e.g., & or ;).

Leave a Reply

Your email address will not be published. Required fields are marked *