Visually Enforced

a blog by Gaston Sanchez


Mac Keyboard Shortcut to Open RStudio

Posted on April 09, 2014

In this post I will show you how to create your own keyboard shortcut to open RStudio (or any other application) in a mac.

I use RStudio for my daily work with R so I constantly find myself clicking on the small RStudio icon on the dock of my macbook every time I want to open it. The problem is that I became kind of tired of having to look for the icon, position the mouse pointer on it, clicking the icon, and then moving the mouse inside of the file’s window to start working.

No more clicking on icons! I decided to create a keyboard shortcut (⌘ + control + R) to launch Rstudio as well as other applications that I use very often.

Creating your own keyboard shortcut

To create my keyboard shortcut I followed a very nice tutorial by Josh Jonhson: How to Launch Any App with a Keyboard Shortcut

I will walk you through the general game plan listed below, describing the details of each step. The process involves two major task. The first task involves creating a service to launch an application (RStudio in our case). The second task consists in associating a keyboard shortcut to the launching application service.

  1. Creating Launching Application Service
    • Open Automator
    • Select Service
    • Indicate Launch Application as Service
    • Select the application to be launched
    • Give the launching service a name and save it
  2. Associating a Keyboard Shortcut
    • Open System Preferences
    • Select Keyboard Shortcut
    • Add application shortcut
    • Select the launching service
    • Indicate your own combination of keys

Creating a Launching Application Service

Go to Applications and open Automator which is the white little cyclopean robot

After clicking Automator, a window will be prompted asking you to choose a type for your document. Just choose Service (i.e. the gear icon)

Once inside the Service menu, you’ll see a bunch of icons in the sidebar menu on the left. Scroll down until you find the icon Launch Application which you need to open.

As you can tell, you need to specify the application you want to launch: RStudio in this case.

Change the default value text associated to Service receives selected into no input.

The next step is to save the service which requires you to give it a name. In my case I’m saving the service under the name Launch Rstudio but you can use whatever name you want.

Associating a Keyboard Shortcut to the Launching App Service

We’re done with specifying a launching service for RStudio. Now we need to create a keyboard shortcut that we can use to launch RStudio. To do this, you need to go to System Preferences and open the Keyboard icon.

Once inside the Keyboard menu you have to select the tab Keyboard Shortcuts. Click on the + symbol at the bottom to add an application shortcut.

Click on the Services icon (i.e. the gear) and look for the name you gave it to the launching service (eg in my case is Launch Rstudio).

Finally, click on the add shortcut button and indicate what combination of keys you want to be associated as a shortcut.

I decided to use the keys ⌘ + ctl + R but you can select a different combination. Just be careful not to use already existing keyboard shortcuts.

That’s it! Enjoy your keyboard shortcut.


Published in categories resources  Tagged with R  RStudio  keyboard