RStudio user preferences for your runs (such as theme) are stored in a file in /home/ubuntu/.rstudio/monitored/user-settings/user-settings
.
To launch RStudio with custom preferences, you can use the pre-setup script in a custom compute environment to modify this file.
If you know what to add to the settings file, you can write it in the pre-setup script. For example:
mkdir -p /home/ubuntu/.rstudio/monitored/user-settings/ <b class="conum">(1)</b>
echo 'uiPrefs={"theme" : "Mono Industrial"}' >> /home/ubuntu/ .rstudio/monitored/user-settings/user-settings <b class="conum">(2)</b>
chown -R ubuntu:ubuntu /home/ubuntu/.rstudio <b class="conum">(3)</b>
if [ -f .domino/launch-rstudio-server ]; then
sed -i.bak 's# > ~/.rstudio/monitored/user-settings/user-settings# >> ~/.rstudio/monitored/user-settings/user-settings#' .domino/launch-rstudio-server <b class="conum">(4)</b>
chown ubuntu:ubuntu .domino/launch-rstudio-server <b class="conum">(3)</b>
fi
The following describes what each line is doing:
-
The
mkdir
statement creates the encompassing directory. -
The
echo
statement writes the theme to the file. If you prefer to store a file in your project, you can replace this with a copy operation (see the next method). -
The
chown
statements avoid a permissions error. -
The
sed
statement modifies a Domino script that would overwrite this settings file.
Use this method if do not know what lines to add, or if you want to persist this settings file in your project.
-
Run a session and modify the RStudio preferences as needed.
-
Before you stop the session, use the following R code to copy the
user-settings
file to the root of your project directory.file.copy("/home/ubuntu/.rstudio/monitored/user-settings/user-settings", ".")
-
Add the following lines to the pre-setup script of your environment definition to load the preferences file (if it exists) on subsequent runs:
if [ -f user-settings ]; then mkdir -p /home/ubuntu/.rstudio/monitored/user-settings/ cp user-settings /home/ubuntu/.rstudio/monitored/user-settings sed -i.bak '/initialWorkingDirectory=/d' /home/ubuntu/.rstudio/monitored/user-settings/user-settings chown -R ubuntu:ubuntu /home/ubuntu/.rstudio if [ -f .domino/launch-rstudio-server ]; then sed -i.bak 's# > ~/.rstudio/monitored/user-settings/user-settings# >> ~/.rstudio/monitored/user-settings/user-settings#' .domino/launch-rstudio-server chown ubuntu:ubuntu .domino/launch-rstudio-server fi fi