diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index da94613..2aca111 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -13,7 +13,7 @@ "dockerDashComposeVersion": "v2" } }, - "postCreateCommand": "/bin/bash .devcontainer/postCreate.sh", + "postCreateCommand": "/bin/bash .devcontainer/postCreate.sh ${containerWorkspaceFolder}", "postAttachCommand": { "rstudio-start": "sudo rstudio-server start" }, diff --git a/.devcontainer/postCreate.sh b/.devcontainer/postCreate.sh index cac58e6..3e43d44 100644 --- a/.devcontainer/postCreate.sh +++ b/.devcontainer/postCreate.sh @@ -5,9 +5,9 @@ set -euo pipefail pip3 install --user -r .devcontainer/requirements.in #set R working directory -! grep -q `pwd` $R_HOME/etc/Rprofile.site && sudo tee -a $R_HOME/etc/Rprofile.site <<< "setwd(\"`pwd`\")" +! grep -q "$1" $R_HOME/etc/Rprofile.site && sudo tee -a $R_HOME/etc/Rprofile.site <<< "setwd(\"$1\")" #set RStudio working directory -! grep -q `pwd` ~/.config/rstudio/rstudio-prefs.json && cat ~/.config/rstudio/rstudio-prefs.json | jq ". + {\"initial_working_directory\":\"`pwd`\"}" > ~/.config/rstudio/rstudio-prefs.json +! grep -q "$1" ~/.config/rstudio/rstudio-prefs.json && cat ~/.config/rstudio/rstudio-prefs.json | jq ". + {\"initial_working_directory\":\"$1\"}" > ~/.config/rstudio/rstudio-prefs.json #download and extract latest ehrql source wget https://github.com/opensafely-core/ehrql/archive/main.zip -P .devcontainer