Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I load bash (as opposed to sh) in org babel to enable #+BEGIN_SRC bash?

I see references to, and examples that use

#+BEGIN_SRC bash

But in my org mode version (elpa, org 20150316) in the menu of customize-variable org-babel-load-languages, there is no "bash" item, only shell. Attempting to evaluate code such as

#+BEGIN_SRC bash
ls -l
#+END_SRC

I get

org-babel-execute-src-block: No org-babel-execute function for bash!

What am I missing?

Thanks.

like image 495
mzimmermann Avatar asked Mar 20 '15 09:03

mzimmermann


3 Answers

For me, I did

(require 'package)
(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/") t)

as shown on http://orgmode.org/elpa.html to make sure I had the latest Org version (vanilla Emacs ships with its own version of Org). Then I installed the org package interactively after doing M-x list-packages. Then I could do

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

which allows #+BEGIN_SRC bash.

like image 121
Linus Arver Avatar answered Nov 17 '22 07:11

Linus Arver


See the value of org-babel-sh-command (which defaults to "sh"), and only use "sh" as the language.

like image 39
fniessen Avatar answered Nov 17 '22 07:11

fniessen


It seems bash is covered by the shell identifier.

Therefore, you have to activate insert “Shell Script” in customize-variable org-babel-load-languages.

Tested version: 20150810 from MELPA.

like image 5
Lukas Juhrich Avatar answered Nov 17 '22 07:11

Lukas Juhrich