HOME

Date: [2020-06-16 Tue]

Org Mode

1. Source block without babel backend

When using source blocks that don't have a babel backend add the parameter :exports code to prevent org-mode from complaining about the backend being not found. Because even though the :eval no-export is present, org babel still tries to parse the params and do some stuff with the source block.

So instead of

< Collapse code block> Expand code block
#+begin_src json
  {
    "name" : "Bibek Panthi",
    "species" : "Homo sapiens"
  }
#+end_src

do

< Collapse code block> Expand code block
#+begin_src json :exports code
  {
    "name" : "Bibek Panthi",
    "species" : "Homo sapiens"
  }
#+end_src

2. Literate DevOps

https://howardism.org/Technical/Emacs/literate-devops.html

You can run org babel sh source blocks on remote systems using :dir parameter.

Consider the following:

< Collapse code block> Expand code block
#+begin_src sh :dir /etc :results raw :wrap verbatim
head passwd
#+end_src

This is same as:

< Collapse code block> Expand code block
#+begin_src sh :results raw :wrap verbatim
head /etc/passwd
#+end_src

The :dir parameter accepts anything that emacs accepts for opening files, including paths opened by tramp. For example, if you have a server server.com and you open some file by M-x find-file /ssh:server.com:/home/bpanthi977/test.org. Then in similar way, you can specify :dir parameter to work on a remote directory:

< Collapse code block> Expand code block
#+begin_src sh :dir /ssh:server.com:/etc :wrap verbatim :results raw
head passwd
#+end_src

#+RESULTS:
#+begin_verbatim
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
adm:x:3:4:adm:/var/adm:/sbin/nologin
lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/sbin/nologin
operator:x:11:0:operator:/root:/sbin/nologin
#+end_verbatim

3. Agenda


You can send your feedback, queries here