4

My question relates to making R beep after a command. I understand that I can run beep() together with whatever command I want to run, but is there a way to automatically run beep() (from beepr package) or system("say done") (I run RStudio on a Mac) after every command?

e.g. is there a options() setting I can tweak so that after entering every command in the interpreter another command like beep() is executed?

Community
  • 1
  • 1
hongsy
  • 1,498
  • 1
  • 27
  • 39
  • To clarify: You want to play a sound every time you send code from RStudio to R? I don't think RStudio supports this. Thus, you'd need to hook into R's REPL and AFAIK that's not possible (without changing R's source code and recompiling it). If you were using `source` you could add the beeping to its source code easily, but that's probably not what you are doing. – Roland Nov 02 '16 at 07:40
  • right. basically just a fuss free way of making sure it beeps after every command – hongsy Nov 02 '16 at 07:54
  • See [this R-help post](https://stat.ethz.ch/pipermail/r-help/2010-November/260433.html). – Jonathan Nov 02 '16 at 16:45

1 Answers1

8

You want addTaskCallback.

addTaskCallback(function(...) { system("say done"); TRUE }, name = "announce when done")

Have fun!

Jonathan
  • 8,497
  • 41
  • 35