Skip to content

Commit a86e562

Browse files
CelestineSauvagecelestinesauvage
andauthored
feat(rstudio): add automatic opening of .Rproj on startup if git repository (#333)
* feat(rstudio): add automatic opening of .Rproj on startup * Update onyxia-init.sh --------- Co-authored-by: celestinesauvage <[email protected]>
1 parent ea4d5b2 commit a86e562

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

base/scripts/onyxia-init.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,14 @@ if command -v R &>/dev/null; then
147147
fi
148148
env | grep "KUBERNETES" >> ${R_HOME}/etc/Renviron.site
149149
env | grep "IMAGE_NAME" >> ${R_HOME}/etc/Renviron.site
150+
151+
# Configure rproj in rstudio
152+
if command -v rstudio-server &>/dev/null; then
153+
if [[ -n "$GIT_REPOSITORY" ]]; then
154+
REPO_DIR=$(basename "$GIT_REPOSITORY" .git)
155+
echo "setHook('rstudio.sessionInit', function(newSession) { if (newSession && identical(getwd(), '${WORKSPACE_DIR}')) { message('Activate RStudio project'); rstudioapi::openProject('${REPO_DIR}'); } }, action = 'append')" >> ${HOME}/.Rprofile
156+
fi
157+
fi
150158
fi
151159

152160
if [[ "$DARK_MODE" == "true" ]]; then

0 commit comments

Comments
 (0)