Emacs org-mode - How to run shell scripts with backgrounded processes without hanging Emacs
Here is the closest I can think of using https://github.com/jwiegley/emacs-async
* Run shell command asynchronously
#+BEGIN_SRC sh :tangle some_cmd.sh :tangle-mode (identity #o755) :shebang #!/bin/bash
sleep 10
touch async-file
echo "done"
#+END_SRC
#+RESULTS:
#+BEGIN_SRC emacs-lisp
(require 'async)
(org-babel-tangle)
(async-start
(lambda ()
(shell-command (expand-file-name "some_cmd.sh")))
(lambda (result)
(message-box "%s" result)))
#+END_SRC
#+RESULTS:
: #<process emacs>
#+BEGIN_SRC sh
ls async-file
#+END_SRC
or for your particular use:
(require 'async)
(async-start
(lambda ()
(shell-command "xterm"))
(lambda (result)
(message-box "%s" result)))
I use ob-async from MELPA to enable asynchronous executions.
.emacs:
(require 'ob-async)
.org:
#+BEGIN_SRC sh :async
sleep 10 && echo 'Done!'
#+END_SRC