I often use the terminal built in to Rstudio to run interactive R commands and scripts remotely on a server. Occasionally I end up executing R commands in terminal when R is not running in terminal. This can happen for a number of reasons, but one is that after having run the R command "?library" in terminal, the terminal is actually in the bash shell.
The problem that arises is that R commands often have ">" since this is the command prompt in R, or the command may be "Var1 > Var2". This will inadvertently create files in the remote working directory via the linux redirection operator. I am happy to set noclobber to avoid catastrophic overwrites, but I also want to avoid creating new files.
I can think of several ways to address this. One is to disable the ">" operator for the entire ssh session. My current understanding is that it is not possible without disabling most of bash by running in restricted mode.
I am now wondering about how to implement two other partial solutions.
One is to make the remote R help pages show up in a different color in Rstudio terminal to indicate terminal is running bash. This is not ideal because often the terminal is hidden, for example after running a command locally in the R console.
A better partial solution would be to automatically run bash in restricted mode when it is exposed by calling "?" in the terminal R session. This solution is ultimately just an R question, not an Rstudio question.
Can anyone help with this? Thanks