Skip to content

Instantly share code, notes, and snippets.

@hrbrmstr
Last active August 29, 2015 14:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrbrmstr/15375ec7a873d17ea5e2 to your computer and use it in GitHub Desktop.
Save hrbrmstr/15375ec7a873d17ea5e2 to your computer and use it in GitHub Desktop.
A small script to grab the latest RStudio daily build for OS X and install it.

I like to run the RStudio dailies since Kevin Ushey is always adding good stuff (and it's super-easy to use a stable version if the daily is wobbly).

Rename rsupd.bash to just rsupd (I wanted it to render nicely in the gist so I had to put an extension on it) then put the rsupd script into /usr/local/bin and (from a command prompt) do chmod 755 /usr/local/bin/rsupd

Now, copy the is.rud.UpdateRStudio.plist to ~/Library/LaunchAgents if you want the update to happen automatically. Change the hour/minute if 0730 AM doesn't work for you for some reason. Then use: launchctl load -w ~/Library/LaunchAgents/is.rud.UpdateRStudio.plist to load it (use unload vs load to, well, unload it).

If you want to run it by hand, just enter rsupd as a command prompt.

As stated in the rsupd.bash script, it requires external utilities, so read the comments and ensure you've done that, otherwise the script won't work!

2015-07-29

  • Added instructions for loading job with launchctl
  • Fixed issue in vol=${atch##* }
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>is.rud.UpdateRStudio</string>
<key>Program</key>
<string>/usr/local/bin/rsupd</string>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>7</integer>
<key>Minute</key>
<integer>30</integer>
</dict>
</dict>
</plist>
#!/bin/bash
# this script relies on the W3C HTML XML tools and the "trash" utility
# the easiest way to install them is to install homebrew http://brew.sh/
# then:
# brew install html-xml-utils trash
rstudio_osx_daily_url="https://www.rstudio.org/download/daily/desktop/mac/"
# Get URL for "latest" RStudio daily
url=`curl --silent "${rstudio_osx_daily_url}" | hxselect "tr#row0 > td > a" | sed -e 's/<a /<a /g' | sed -e 's/<a .*href=['"'"'"]//' -e 's/["'"'"'].*$//' -e '/^$/ d'`
# Get just the name of the dmg file
fil=`basename ${url}`
# Download the daily dmg
cd /tmp
rm RStudio*dmg
curl --silent --output "${fil}" "${url}"
# Mount it
atch=`hdiutil attach ${fil}`
# Get the mount location
vol=${atch##* }
# Get rid of the old RStudio app
trash /Applications/RStudio.app
# Put the new one in /Applications
ditto ${vol}/RStudio.app /Applications/RStudio.app
# Unmount the dmg
umount ${vol}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment