Skip to content

Instantly share code, notes, and snippets.

@sachac
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sachac/11090358 to your computer and use it in GitHub Desktop.
Save sachac/11090358 to your computer and use it in GitHub Desktop.
Little snippet to run command in term instead of inserting in region
(defadvice org-babel-execute:sh (around sacha activate)
  (if (assoc-default :term (ad-get-arg 1) nil)
    (let ((buffer (make-term "babel" (or explicit-shell-file-name
                                         (getenv "ESHELL")
                                         (getenv "SHELL")
                                         "/bin/sh"))))
      (with-current-buffer buffer
        (insert (org-babel-expand-body:generic
             body params (org-babel-variable-assignments:sh params)))
        (term-send-input)))
    ad-do-it))
ls -l
echo "Hello world"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment