Closed HenrikBengtsson closed 6 years ago
Asked question on https://community.rstudio.com/t/programmatically-detect-rstudio-terminal-vs-rstudio-console/4107 on how to best distinguish RStudio Console from RStudio Terminal.
Created a feature request for rstudioapi::restartSession()
to provide more control on the new session so startup::restart()
could also work in the RStudio Console.
The RStudio Terminal can be detected by testing for env var RSTUDIO_TERM
not being empty
Part of this added sysinfo()
field rstudioterm
- however, since it's more likely that one which to test for RStudio Console it's probably better to have a unique flag for that instead of as now rstudio=TRUE,rstudioterm=FALSE
.
For convenience and backward compatibility, rstudio
could be the flag for the console only, and rstudioterm
for the terminal.
Fixed in commit d921e85
Contrary to the RStudio Console, it should be possible to restart an RStudio Terminal. However,
restartup()
is too strict (only looks at thestartup::sysinfo()$rstudio
flag) and prevents it from restarting R when running in an RStudio Terminal.