Pretty Print Org Mode files in Terminal
I wanted a nicer way to read org files in the terminal.
Org files are readable enough as plain text, but after a while all the #+BEGIN_SRC blocks, inline markup, and other bits of org syntax start to feel noisy. I mostly just wanted something that would make them easier to skim without having to open Emacs.
I ended up using pandoc to convert the file to Markdown, then piping that into glow.
pandoc -t markdown <file.org> | glowThat’s basically the whole trick.
glow is great for reading Markdown in the terminal, but it doesn’t handle org files directly. Running the file through pandoc first turns out to be good enough for this.
Shell version
First install the two dependencies:
- macOS:
brew install pandoc glow - Debian/Ubuntu:
apt install pandoc glow - Arch:
pacman -S pandoc-cli glow
Then add this function to your shell config:
glow-org() { pandoc -t markdown "$1" | glow; }Reload your shell and use it like this:
glow-org my-notes.orgNix version
If you’re already using Nix, you can package the same thing like this:
{ pkgs }:
pkgs.writeShellScriptBin "glow-org" ''
#!${pkgs.bash}
if [ $# -eq 0 ]; then
echo "Usage: glow-org <file.org> [options]" >&2
exit 1
fi
${pkgs.pandoc}/bin/pandoc -t markdown "$1" | ${pkgs.glow}/bin/glow
''Add it to your environment or home packages and run it the same way:
glow-org my-notes.orgIt’s a tiny wrapper, but it’s convenient enough that I actually use it. This is really just for reading, not for perfectly preserving every org feature, but for that it works well.