Change The Default “Shell…” Action In RStudio for OS X
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
RStudio is my R development environment of choice and I work primarily on/in Mac OS X. While it’s great that Apple provides a built-in Terminal application, I prefer to use iTerm 2 when I need to do work at a shell. The fine folks at RStudio provide a handy Shell… menu item off the Tools menu, but it (rightly) defaults to using Apple’s Terminal.app for functionality since they can’t assume what terminal application you are using.
To change it to iTerm (or whatever your favorite terminal application is) you need to fire up a text editor and change (make a backup first!) /Applications/RStudio.app/Contents/MacOS/mac-terminal to contain the following modified AppleScript:
#!/usr/bin/osascript
on run argv
set dir to quoted form of (first item of argv)
tell app "iTerm"
activate
tell the first terminal
launch session "Default Session"
tell the last session
set name to "RStudio Session"
write text "cd " & dir
end tell
end tell
end tell
end run |
That will open a new tab in iTerm, set the session (tab) name to “RStudio Session” and change the directory to the current working directory in RStudio.
More often than not, I’m just using Alfred to kick up iTerm and doing the cd myself, but this added tweak (which you have to do every time you upgrade RStudio) reduces the churn when I do end up using the feature within RStudio.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.