mzimmermann
mzimmermann

Reputation: 1072

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.

Upvotes: 30

Views: 22287

Answers (4)

user176145
user176145

Reputation:

if you are using straight/ use-package try this:-

(use-package ob-shell
  :straight nil
  :after org
  :config
  (setq org-babel-default-header-args:sh '((:results . "output")))
  (setq org-babel-default-header-args:shell '((:results . "output"))))

Upvotes: 2

Linus Arver
Linus Arver

Reputation: 1378

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.

Upvotes: 29

Lukas Juhrich
Lukas Juhrich

Reputation: 395

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.

Upvotes: 6

fniessen
fniessen

Reputation: 4516

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

Upvotes: 5

Related Questions