0

I have an org file with notes about how to setup my project. One of the notes has some shell scripts, like this:

#+begin_src sh :dir ~/Workspace/MyProject :session cmake-setup
cmake -B build-debug -S . -G Ninja \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_BUILD_TYPE=Debug
#+end_src

I can hit C-c C-c there and execute the shell command. But the problem is that Emacs hangs for 5-10 seconds while that command runs. When it's done I can switch to the cmake-setup buffer and see the output. But I'd like to switch to the shell buffer right away and see the progress. This will be essential when commands take more than a few seconds.

I found ob-async and added the :async header to the source block. It stops freezing emacs, but it ignores the :session header and puts the huge amount of output into my org file.

Is there a way to make my code block execute asynchronously and keep it running in the session?

3
  • 2
    Not sure, but doesn't the ampersand at the end of your shell command help?
    – Arktik
    Commented Mar 20, 2023 at 16:37
  • 1
    You can set the :results silent for the block if you don't want to see a huge output.
    – Arktik
    Commented Mar 20, 2023 at 16:39
  • Oh my, I'm an idiot. Haha. Yes, the & did it. Thank you.
    – Rob N
    Commented Mar 20, 2023 at 16:48

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.