2020-06-16

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

#+begin_src json
  {
    "name" : "Bibek Panthi",
    "species" : "Homo sapiens"
  }
#+end_src

do

#+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:

#+begin_src sh :dir /etc :results raw :wrap verbatim
head passwd
#+end_src

This is same as:

#+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:

#+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. Show headings in beamer

Add the following to the top of org file:

#+begin_export latex
\\AtBeginSection[]{
  \\begin{frame}
  \\vfill
  \\centering
  \\begin{beamercolorbox}[sep=8pt,center,shadow=true,rounded=true]{title}
    \\usebeamerfont{title}\\insertsectionhead\\par%
  \\end{beamercolorbox}
  \\vfill
  \\end{frame}
}
#+end_export

4. Add section break after each section

#+begin_export latex
\let\oldsection\section
\renewcommand\section{\clearpage\oldsection*}

\clearpage
#+end_export

5. No section numbering in latex export

#+BEGIN_EXPORT latex
\let\oldsection\section
\renewcommand\section{\clearpage\oldsection*}

\clearpage
#+END_EXPORT

6. Agenda


References

Backlinks


You can send your feedback, queries here