Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I’m trying to call textoc from OS X Application Alfred as a shell script.

alfred window

And with Alfred everything seems fine—I already asked the developers but they say that the script should work. When debugging I get the message

21.9.11 17:14:12
[0x0-0x40040].com.alfredapp.Alfred[977]
env: texlua: No such file or directory

therefore I guess it’s a problem with texdoc and not with Alfred. I get the same error if I call texdoc with an apple script

do shell script "texdoc file"

But when calling texdoc file directly in my Terminal or in not-silent mode of Alfred (which means a terminal window opens and the command is executed) everything works. A shell script (td.sh)

#!/bin/bash
texdoc $1

called with sh td.sh file works too.

Hope that anyone has an idea how to solve this or at least point where I can get help …

share|improve this question
2  
I guess that the default shell doesn't know about the correct path to the binaries. On my system, osascript -e 'do shell script "texdoc amsmath"' does what's expected. What's the answer to osascript -e 'do shell script "echo $PATH"' given to the terminal? –  egreg Sep 21 '11 at 16:09
    
@egreg: Mille grazie! That leads me to the solution. If you post your text as an answer I’d upvote and accept it :-) –  Tobi Sep 21 '11 at 16:28

2 Answers 2

up vote 5 down vote accepted

It's quite strange, with MacTeX, that the default shell, which is called when a shell script is executed via AppleScript, doesn't have /opt/texbin/ in the PATH variable.

It depends on the version of Mac OS X you're running. On Mac OS X 10.5 and 10.6, there should be a file called TeX in /etc/paths.d/, containing just the line

/usr/texbin

If it's not there, then something has gone wrong with your installation of MacTeX. It's quite easy to correct the behavior: do the following from a terminal window

echo /usr/texbin > TeX
sudo mv TeX /etc/paths.d

and a logoff-login cycle should bring the system into shape. However I don't have a 10.7 machine available, so if your system version is this one, wait for comments.

Check also that a file TeX is present also in /etc/manpaths.d/; if not,

echo /Library/TeX/Distributions/.DefaultTeX/Contents/Man > TeX
sudo mv TeX /etc/manpaths.d

is needed in order to access to the man pages for the TeX programs.

share|improve this answer
    
I got both files. My TeX system works fine I guess, but texdoc is only available form Alfred if I add the PATH to the script. And in TeXmakerx I need to write "/usr/texbin/latex" instead of latex to make it work. But then everything works fine. –  Tobi Sep 21 '11 at 19:22

Tobi gave an answer with an Alfred v1 extension; however, extensions are no longer supported with the v2 release, which now uses "workflows." I created a workflow for texdoc using the information on this page.

The critical part of the workflow (which is really simple) is the Bash script, which uses egreg's answer to determine the TeX path:

export PATH=$PATH:`cat /etc/paths.d/TeX`
texdoc {query}

This script works with (at least) TeX Live 2013.

Edit: Updated to reflect that Tobi removed his answer.

share|improve this answer
    
Thanks for the update. I updated the workflow on my computer but forget about this question. You may like to include my icon in your’s?! Send me an email (mail@tweh.de) and I’ll send you the icon files … –  Tobi Nov 7 '13 at 18:37

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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