positron icon indicating copy to clipboard operation
positron copied to clipboard

Set `POSITRON` environment variable in Terminal and Python console as well

Open gadenbuie opened this issue 1 year ago • 1 comments

In the R console in Positron, the POSITRON environment variable is set to 1. This is helpful for identifying when R code is being evaluated inside Positron.

It would be helpful if this environment variable could also be set for terminal sessions started from Positron. I frequently start additional R console sessions using the terminal tab (yes, even in Positron because these terminal tabs can be moved around anywhere in the UI) and I rely on this environment variable to avoid running RStudio- or VS Code-specific R code stored in my .Rprofile. This would also match the behavior in RStudio, where echo "$RSTUDIO" returns 1 in the RStudio terminal.

Additionally, for consistency and future Python endeavors, it'd be helpful if this environment variable were also set for Python console sessions.

>>> # Currently...
>>> import os
>>> os.getenv("POSITRON")
>>>

gadenbuie avatar Jul 03 '24 14:07 gadenbuie

Related to #3776 Related to #2723

juliasilge avatar Jul 03 '24 15:07 juliasilge

For R and Python at least:

https://github.com/posit-dev/positron/blob/5aefc15859e0837751e1db1b837e1ecb160b961c/extensions/jupyter-adapter/src/JupyterKernel.ts#L728-L729

juliasilge avatar Jul 08 '24 21:07 juliasilge

Verified Fixed

Positron Version(s) : 2024.07.0-27 OS Version(s) : Windows 11, MacOS 14

Test scenario(s)

POSITRON environment variable set to 1 in all terminals and consoles

Link(s) to TestRail test cases run or created:

None

jonvanausdeln avatar Jul 10 '24 15:07 jonvanausdeln