From f7819018deb05094c3b75d6687c7828309c46972 Mon Sep 17 00:00:00 2001 From: celestinesauvage Date: Wed, 10 Dec 2025 11:46:12 +0000 Subject: [PATCH 1/2] feat(rstudio): add automatic opening of .Rproj on startup --- base/scripts/onyxia-init.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/base/scripts/onyxia-init.sh b/base/scripts/onyxia-init.sh index 75a2392e..105e5b7a 100755 --- a/base/scripts/onyxia-init.sh +++ b/base/scripts/onyxia-init.sh @@ -147,6 +147,14 @@ if command -v R &>/dev/null; then fi env | grep "KUBERNETES" >> ${R_HOME}/etc/Renviron.site env | grep "IMAGE_NAME" >> ${R_HOME}/etc/Renviron.site + + # Configure rproj in rstudio + if command -v rstudio-server &>/dev/null; then + if [[ -n "$GIT_REPOSITORY" ]]; then + REPO_DIR=$(basename "$url" .git) + echo "setHook('rstudio.sessionInit', function(newSession) { if (newSession && identical(getwd(), '${WORKSPACE_DIR}')) { message('Activate RStudio project'); rstudioapi::openProject('${REPO_DIR}'); } }, action = 'append')" >> ${HOME}/.Rprofile + fi + fi fi if [[ "$DARK_MODE" == "true" ]]; then From bf681f678875aeab3c5be4ca864e467629751ff2 Mon Sep 17 00:00:00 2001 From: CelestineSauvage Date: Wed, 10 Dec 2025 14:47:22 +0100 Subject: [PATCH 2/2] Update onyxia-init.sh --- base/scripts/onyxia-init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base/scripts/onyxia-init.sh b/base/scripts/onyxia-init.sh index 105e5b7a..bc156db5 100755 --- a/base/scripts/onyxia-init.sh +++ b/base/scripts/onyxia-init.sh @@ -151,7 +151,7 @@ if command -v R &>/dev/null; then # Configure rproj in rstudio if command -v rstudio-server &>/dev/null; then if [[ -n "$GIT_REPOSITORY" ]]; then - REPO_DIR=$(basename "$url" .git) + REPO_DIR=$(basename "$GIT_REPOSITORY" .git) echo "setHook('rstudio.sessionInit', function(newSession) { if (newSession && identical(getwd(), '${WORKSPACE_DIR}')) { message('Activate RStudio project'); rstudioapi::openProject('${REPO_DIR}'); } }, action = 'append')" >> ${HOME}/.Rprofile fi fi