[TxMt] Re: Command input as a shell variable

Jonathan Clayden jon.clayden at gmail.com
Fri Jul 14 20:24:40 UTC 2006


On 14/07/06, Ana Nelson <nelson.ana at gmail.com> wrote:
> Yes, or also:
>
> cat `find /Library/Frameworks/R.framework/Versions/Current/Resources/
> library -name "$TM_CURRENT_WORD.html" -print`
> or
> cat `find /Library/Frameworks/R.framework/Versions/Current/Resources/
> library -name "$TM_CURRENT_SELECTION.html" -print`
>
> would work here too.

True, although it's useful to let TM itself decide whether to use word
or selection.

> Once you open an R help page in this way, the hyperlinks don't work.
> Anyone know if it's possible to fix that?

Back to Ruby! This is a little quick and dirty, but it seems to work fine:

#! /usr/bin/ruby
text = STDIN.read
file = `find /Library/Frameworks/R.framework/Versions/Current/Resources/library
-name #{text}.html -print`
unless file.empty?
	dir = File.dirname(file)
	html = `cat #{file}`
	print html.gsub(/href=['"]([^'"]+)['"]/, "href=\"tm-file://#{dir}/\\1\"")
end



More information about the textmate mailing list