Skip to content

Instantly share code, notes, and snippets.

@amake
Last active December 13, 2021 13:10
Show Gist options
  • Save amake/3aa93948a19b82deb5b063939a57bfb0 to your computer and use it in GitHub Desktop.
Save amake/3aa93948a19b82deb5b063939a57bfb0 to your computer and use it in GitHub Desktop.
org-babel + tramp demonstration

This file demonstrates using org-babel and tramp together to execute a source block on a remote host. It was tested with Emacs 27.1 launched as emacs -Q (zero custom configuration).

I recommend that you download the raw version of this file, open it in Emacs, and evaluate the blocks yourself. In fact, if you don’t then you will miss the most important parts because they are hidden in the fancy GitHub rendering.

Setup

By default org-mode only allows evaluating elisp.

Enable shell as well by evaluating the following: Place your point anywhere on the block and do C-c C-c.

(org-babel-do-load-languages
 'org-babel-load-languages
 '((emacs-lisp . t)
   (shell . t)))

Now you can evaluate the following block:

uname -a

With Tramp

To evaluate a block on a remote machine via Tramp, set the :dir header value appropriately with Tramp syntax. Here, thrillho is the hostname of a machine on my local network.

uname -a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment