Vscode-r: Run/Source commands not friendly to user started R session

Created on 17 Sep 2019  路  9Comments  路  Source: Ikuyadeu/vscode-R

In my use case, I usually work with remote development via SSH on remote machine and most of the time I also need to start a R session in a tmux window so that the session is preserved.

Therefore, Run or source command should work with the session I start in tmux rather than start a new session. PR #104 partially solves this problem stated in #80, but most run-code related commands should be able to send code to active terminal.

However, it may not make sense to have all commands split into original version and Active Terminal version. I'm wondering if it makes sense to add an option to opt out the behavior to always start a R session if no session started by vscode-R extension is detected?

feature-request

Most helpful comment

For plots, I find X11 forwarding is not working well even if the white window shows the experience is not good.

I write a default device in .Rprofile (see https://github.com/renkun-ken/dotfiles/blob/master/.Rprofile#L6-L26), and it produces png files to .images folder in the working directory and always write the last plot to latest-%d.png. Each time a new plot is generated, the current latest-%d.png files are renamed to time-stamp file name so that history plots are stored. In vscode, you only need to open latest-1.png and you can preview the file instantly when the device is closed.

Kapture 2019-09-30 at 22 10 19

All 9 comments

This sounds good to me, and I think is definitely a better approach than having original/Active Terminal versions for all commands. I would use this option too.

I would like to add also,
The current behavior of ctrl+enter is to run selected lines in the current terminal. In case no R session is active, it will start one.
Would be nice if ctrl+enter can detect if the active terminal is connected to ssh or not, and then launch an R session based on the ssh status (R over the remote machine or the local machine). This is important since making plots is not allowed via the remote R.

Hi @hmassalha, I don鈥檛 think there鈥檚 a way of checking whether the active terminal is connected to ssh or not.

It may be possible to get plots displaying using port forwarding if that鈥檚 available (https://stackoverflow.com/a/3453318) but I haven鈥檛 tried that myself.

Thanks for your note, I am not managing to set the forwarding ports!

For plots, I find X11 forwarding is not working well even if the white window shows the experience is not good.

I write a default device in .Rprofile (see https://github.com/renkun-ken/dotfiles/blob/master/.Rprofile#L6-L26), and it produces png files to .images folder in the working directory and always write the last plot to latest-%d.png. Each time a new plot is generated, the current latest-%d.png files are renamed to time-stamp file name so that history plots are stored. In vscode, you only need to open latest-1.png and you can preview the file instantly when the device is closed.

Kapture 2019-09-30 at 22 10 19

Thanks for your suggestion.
I found the following https://github.com/cloudyr/rmote is a nice solution. You can generate and update the same plot several times, while the browser will keep the previous ones.

*I noticed you have a colored terminal, how I can get something similar? Thanks,

For the R terminal I use, please checkout radian.

I will work on this (option to make all commands use the active terminal) next.

Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nathaneastwood picture nathaneastwood  路  6Comments

LePeti picture LePeti  路  4Comments

renkun-ken picture renkun-ken  路  3Comments

Kalaschnik picture Kalaschnik  路  4Comments

bdeshon picture bdeshon  路  3Comments