If I run the following babel shell blocks
#+BEGIN_SRC sh :session one :results output
ssh staging
#+END_SRC
#+BEGIN_SRC sh :session one :results output
hostname
#+END_SRC
Org creates a shell buffer called one
, runs ssh staging
and then after connecting, executes hostname
on staging. However, if I tweak the ssh command and run it again it attempts to run it from within session one, from the staging host. If I close the buffer one
it resets the session as the next time any command is run with that session name it recreates it. What I haven't been able to find is a method to force a particular babel block to always initialize a new session.
I'm aware that for some languages (elisp in particular) this would not be possible. I suppose I could prepend the session with an elisp block containing (kill-buffer "one")
, but would rather this was a header argument if possible. I'm also aware that for this example I could simply combine the two into a single block with no session, but I'm interested in more complicated sequences.
Is there a :prologue
command or some other special argument to :session
that forces that block to initialize a new shell on every invocation?
org-babel-initiate-session
.