Customize Terminal on startup of RStudio

I would like to find out how to customize the terminal window upon startup of my session on RStudio Server or, even better, upon switching to a project within RStudio. Specifically, upon start of my session or project, I want to have two terminal windows named Server1 and Server2. Server1 would be the normal, current server where RStudio Server is running and Server 2 would be a different server reached through ssh. I would also want the hostname command to run on each of the two servers to confirm I am successfully on those servers. I am currently doing all of this manually and would like it to be automated. Thanks .

I think I have found an answer: rstudioapi:terminal* commands! Something like:

termId1 = rstudioapi::terminalCreate(caption="Server1", show = TRUE)
rstudioapi::terminalSend(termId1, "hostname; \n")
termId2 = rstudioapi::terminalCreate(caption="Server2", show = TRUE)
rstudioapi::terminalSend(termId2, "ssh uid@server; hostname; \n")

1 Like