Skip navigation

2013-09-16 UPDATE: I took suggestions from a couple comments, expanded the function a bit and stuck it in a gist. See this comment for details.

The data retrieval and computation operations are taking longer and longer as we start cranking through more security data and I’ll often let tasks run in the background whilst performing more mundane tasks or wasting time on Twitter. For folks using RStudio Desktop on a Mac, you can use the #spiffy terminal-notifier from Julien Blanchard (@julienXX) wrapped in a cozy little R function to alert you when your long-running jobs are complete.

After a quick “gem install terminal-notifier” you just need to add this notify() function to your R repertoire:

notify <- function(message="Operation complete") {
  system(sprintf("/usr/bin/terminal-notifier -title 'RStudio' -message '%s' -sender org.rstudio.RStudio -activate org.rstudio.RStudio",
         ignore.stdout=TRUE, ignore.stderr=TRUE, wait=FALSE)

and add a call to it right after a potentially long-running operation to get a clickable notification right in the Notification Center:

system("sleep 10")
notify("long computation complete")


I’m working on a way to send notifications from RStudio Server when using one of the standalone clients mentioned in a previous post, so stay tuned if you need that functionality as well.


  1. Thanks for this useful snippet. FIY I also had it working on the mac default R GUI without extra manipulation. =)

  2. For Ubuntu users, it works pretty much the same with “notify-send”.
    Like: system(“notify-send ‘Calcul terminé’ -i /usr/lib/rstudio/rstudio.png”)
    Thanks for the idea!

    • this sounds like it’s begging for a module. lemme see what I can throw together. :-)

  3. Very nice! You can use it with the standard R GUI by replacing “org.rstudio.RStudio” with “org.R-project.R”. Then a click on the message brings you to the R GUI instead of RStudio.

  4. I put the function in a gist, added support for RStudio & R GUI (and it even cascades nicely down to message() for R console work). I’ll be updating the gist if any more tips come in. If linux users wish to clone it and modify it to make it it more os-agnostic, I’ll make a note of it in the main gist.

One Trackback/Pingback

  1. […] received a couple follow-ups to the OS X notifications on RStudio Desktop for the Mac post, I was determined to find a quick hack to get remote notifications to OS X working from (at […]

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.