5

I would like a command such as this:

\href{../src/wkfl/vlyUpstrOvrlp.sh}{vlyUpstrOvrlp}

but I want the subsequent link to open the file in gedit or the default text editor in linux. Bonus points if it also works in windows.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
denilw
  • 3,156
  • 5
    I think that whatever happens with the hyperlink when clicked depends on your pdf viewer. – Juan A. Navarro Sep 07 '10 at 16:53
  • if you can run a windows calculator with the following command: \href{run:./calc.exe}{CALCULATOR} why can't you open a file in gedit? – denilw Sep 07 '10 at 17:11
  • 1
    Well the PDF viewer has to be configured to allow it of course ;-) But if the calculator example works, have you tried the obvious substitution? \href{run:/usr/bin/gedit ../src/wkfl/vlyUpstrOvrlp.sh}{vlyUpstrOvrlp}? What goes wrong with it? – David Z Sep 07 '10 at 21:23
  • I haven't tried the calculator but I found it on the internet here: http://www.latex-community.org/forum/viewtopic.php?f=5&t=2746 If I use a absolute path such as: \href{run:/usr/bin/gedit ~/Desktop/hg18.chrom.sizes}{hg18.chrom.sizes} then I get the error "No application found for opening file of mimetype application/octet-stream". If I use a relative path such as \href{run:/usr/bin/gedit ../src/wkfl/vlyUpstrOvrlp.sh}{vlyUpstrOvrlp} then i believe it is opening the new file "gedit ../src/wkfl/vlyUpstrOvrlp.sh" located in /usr/bin/ with gedit – denilw Sep 07 '10 at 22:11
  • clicking on the link generated by \href{run:/usr/bin/gedit ~/research/trunk/src/wkfl/vlyUpstrOvrlp.sh}{vlyUpstrOvrlp} doesn't do anything at all, even though that file exists. – denilw Sep 07 '10 at 22:14
  • I haven't tried the calculator only because I don't have windows. – denilw Sep 07 '10 at 22:19
  • 1
    Try adding the line 'application/octet-stream; gedit %s' to your .mailcap file. It may be that your PDF viewer wisely refuses to run applications not said to be safe in your mailcap file, as a safety precaution. Do say what you are using to view the PDF. – Charles Stewart Sep 08 '10 at 09:35
  • Thank you for the tip. I was not previously aware of this mailcap file but I am looking up info on it. – denilw Sep 08 '10 at 16:28

1 Answers1

5

Make a small script "rungedit" containing

#!/bin/bash --
gedit /path/to/vlyUpstrOvrlp.sh

and use

\href{run:rungedit}{vlyUpstrOvrlp}

in your document. This works for me in Acrobat Reader on Linux.

Martin Heller
  • 11,391
  • 1
    In my Linux (Fedora 19) and Acrobat Reader (9.4.1) this actually opens (to edit) the file rungedit, instead of /path/to/vlyUpstrOvrlp.sh – alfC Jul 21 '13 at 10:17
  • I found that it is more robust to give the script and extension (e.g. an invented extension name, like .mygedit or simply .sh and associate that extension with execution of bash. Associations can be specified by generating a application .desktop file and then choosing a default action for the extension. https://ask.fedoraproject.org/en/question/9735/how-do-i-launch-jar-files-using-nautilus/?answer=15275#post-id-15275 (at least in Linux). – alfC Nov 22 '14 at 01:26