I work remotely to Linux servers, writing R scripts with ESS. Rstudio works well if I have a fast and stable GUI-based remote desktop connection to the server. Rstudio server also works OK if I have the server running and now problems with managing logins. However, these two choices are not available on the server. So, Emacs+ESS is a great choice for code editing experience. The catch is, I will have to download generated images and PDF to my local computer to see them. That is not a workflow I want to do every couple of minutes. Doing a SSHFS mount to local computer is a better, but is still not the workflow I want. The ideal workflow:

  1. Write code in an emacsclient inside a tmux session
  2. Run code to generate plots, or PDFs from Rmarkdown
  3. Preview the files right afterward inside the emacsclient window, or in another tmux split, or Window.

This threads discusses various options to view images in the terminal. There is pdf-tools package for emacs to preview PDF documents. So, I believe it is technically possible at the moment. But I don't use emacs so frequent these days so my reflex is a bit rusty. Some guidance/demo setup code will be really appreciated.

1 Answer 1


If you run Emacs on your local machine, and open files on the remote machine via Tramp, you can view remote files as if they were on your local machine, you don't need to do anything special. ESS also uses Tramp to run an R process on your remote machine:

My workflow is:

  1. open emacs locally
  2. edit file on remote machine, via C-x C-f /ssh:remotehost:myRScript.R
  3. start a new R process (either directly via M-x R, or by running a line from my script via C-c C-n etc

After this, you are editing in your local environment (with full graphical support), R is running on your remote machine, and Tramp manages the connection for you.

If you generate a plot, e.g.,

jpeg(file = "myplot.jpeg")

You can open it for viewing via C-x C-f myplot.jpeg from your script file.

If you use org mode, this is even easier: you specify the output file for each code block, and org will insert a link to that file after you run the code. Click the link, and the file (on your remote machine) opens in your local Emacs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.