[R-SIG-Mac] Shortcut for launching command line R?

Simon Urbanek simon.urbanek at r-project.org
Fri Jan 24 04:41:46 CET 2014


On Jan 23, 2014, at 9:40 PM, Dave Deriso <deriso at gmail.com> wrote:

> for OSX just add this to your ~/.bash_profile  alias r=’/Library/Frameworks/R.framework/Resources/R’  ...open terminal and type r 
> 
> bam!
> 

Well, in Terminal you don't need any alias - just type R

But that was not Reijo's question ... he didn't want to start Terminal manually ...


> On Thu, Jan 23, 2014 at 5:56 PM, Simon Urbanek <simon.urbanek at r-project.org> wrote:
> That seems a bit convoluted to me. For a clickable document you can simply create R.command containing single line
> R
> 
> If you want an app, just open the Automator, pick Application type, select "Run Shell Script" with single line
> open -a Terminal /usr/bin/R
> 
> Cheers,
> Simon
> 
> 
> On Jan 23, 2014, at 6:09 PM, Reijo Sund <reijo.sund at helsinki.fi> wrote:
> 
> > There have recently been some problems while running packages using Tcl/Tk with R.app GUI under Mac Os X Mavericks (10.9). It is also well known that it is not a good idea to work with R.app and a custom builded R that uses the Aqua version of Tcl/Tk.
> >
> > Simple solution for these problems is to use command line R (i.e. R in terminal window) instead of R.app GUI. Although it is not particularly difficult to launch terminal application and then R from the prompt, it would be nice to have an icon on the dock to launch the command line R with one click.
> >
> > After some experiencing with AppleScript, I ended up with the following script. There was a need for some ”fine tuning” to deal with problems of Terminal app scripting without manually changing preferences of Terminal app (problems include that in certain cases more than two windows are created instead of one and that it is not trivial to close (only) the correct window after quitting R under the default settings of terminal).
> >
> > -----------------
> >
> > property commandString : "R --no-save --no-restore; screen osascript -e 'tell application \"Terminal\" to close (every window whose name contains \"Survo R\")'; exit 0"
> >
> > tell application "System Events"
> >       if (count (processes whose name is "Terminal")) is 0 then
> >               tell application "Terminal"
> >                       activate
> >                       do script commandString in window 1
> >
> >                       tell window 1
> >                               set custom title of first tab to "Survo R"
> >                       end tell
> >               end tell
> >       else
> >               tell application "Terminal"
> >                       activate
> >                       do script commandString
> >                       set currWin to index of first window
> >
> >                       tell window currWin
> >                               set custom title of first tab to "Survo R"
> >                       end tell
> >               end tell
> >       end if
> > end tell
> >
> > -----------------
> >
> > The script can be run in AppleScript editor (located in /Applications/Utilities/AppleScript Editor), but for the actual use it is useful to File->Export it to Application. Created app works just like any other Mac OS X application and you can drag it to the dock to get the functionality to launch command line R with one click.
> >
> > It is certainly unnecessarily complicated for novice users to create the app themselves, so the distribution of the final app (instead of the script) would probably be a more reasonable idea. It is also likely that there are better, safer and more portable ways to provide such a functionality (across Mac OS X versions), but at least the basic idea can be tested with the script above.
> >
> > So, finally, my question is: Would it be a possible and maybe even a good idea to include this kind of Rterm shortcut app functionality to the R binary for Mac OS X distribution or to make it available from some of the official R Mac OS X pages?
> >
> > Best wishes,
> > Reijo Sund
> >
> > _______________________________________________
> > R-SIG-Mac mailing list
> > R-SIG-Mac at r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> >
> 
> _______________________________________________
> R-SIG-Mac mailing list
> R-SIG-Mac at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-mac
> 



More information about the R-SIG-Mac mailing list