Skip to content

any way to tell R.app to clear console (other than simulating cmd-option-L)?

3 messages · Hans-Jörg Bibiko, Timothy Bates

#
Dear R-guys,

I?d like to send an applescript command to R.app (from Textmate) to clear the console (as is achieved by ?Edit:Clear Console?)

Is there an R function that achieves that, or calls R.app?s menu items?

Best, tim
#
On 5 Jul 2011, at 19:58, Timothy Bates wrote:

            
Hi Tim,
simply call this AppleScript which sends the key equivalent ??L to R.app

tell application "R"
	activate
	tell application "System Events"
		keystroke "l" using {command down, option down}
	end tell
end tell

Cheers,
--Hans

**********************************************************
Hans-Joerg Bibiko
Max Planck Institute for Evolutionary Anthropology
Department of Linguistics
Deutscher Platz 6     phone:   +49 (0) 341 3550 341
D-04103 Leipzig       fax:     +49 (0) 341 3550 333
Germany               e-mail:  bibiko[-at-]eva.mpg.de
#
Thanks Hans!
I was hoping to avoid relying on simulating keypresses and the consequent context switch.

but it does the trick, so. 

osascript -e 'on run(theCode)' \
          -e 'tell application "R64" to activate' \
          -e 'tell application "System Events" to keystroke "l" using {command down, option down}' \
          -e 'tell application "TextMate" to activate' \
	  -e 'end run?

Probably best saved as a workflow, to reduce dependency on one editor.
So, as a Services workflow (to install in the new and improved OS X services system)
~/Library/Services