3

I would like to open PDFs (say, with evince) by clicking in the terminal.

The setup is urxvt in Fedora 19 here, but if urxvt cannot do this, can you let me know which terminal emulators can. I got URL detection working by putting:

urxvt*perl-lib: /usr/libi64/urxvt/perl/
urxvt*perl-ext-common: default,matcher
urxvt*matcher.button: 1
urxvt*url-launcher: /usr/bin/xdg-open

Into my ~/.Xdefaults and running xrdb -load ~/.Xdefaults, so hopefully there is some similar solution for the problem at hand.

1
  • 1
    What do you want to click on? A URL like http://example.com/something.pdf? Or just a file name that's displayed on the terminal? Is the problem to get xdg-open to launch evince? – Gilles 'SO- stop being evil' Aug 19 '14 at 22:40
1

I think I found the answer. One has to look at

/usr/lib64/urxvt/perl/matcher

and there they give examples. My usecase is to do

find . | grep -i something

and get a bunch of lines like

./foo/bar/something1.pdf
./bar/foo/something-and-else.pdf

so that adding the two lines

urxvt*matcher.pattern.1:  \\B(./\\S+?).pdf
urxvt*matcher.launcher.1: evince $1.pdf

seems to do the job. I am quite clueless about perl regular expressions, so this is not ideal. E.g.,

./foo/bar/something.pdf.trashinfo

will be caught (it shouldn't - it is not a PDF file!), whereas

./foo/barname barsurname - something.pdf

will not be caught due to the whitespaces. Perhaps somebody can write something more elegant.

Thanks to everyone who took interest in this, cheers!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.